# Buggy code
def check_value_shape(self, value, slice_):
    """Checks if value can be set to the slice"""
    if None not in self.shape and self.dtype != "O":
        if not all([isinstance(sh, int) for sh in slice_]):
            expected_value_shape = tuple(
                [
                    len(range(*slice_shape.indices(self.shape[i])))
                    for i, slice_shape in enumerate(slice_)
                    if not isinstance(slice_shape, int)
                ]
            )

            if isinstance(value, list):
                value = np.array(value)
            if isinstance(value, np.ndarray):
                if value.shape[0] == 1 and expected_value_shape[0] != 1:
                    value = np.squeeze(value, axis=0)
                if value.shape[-1] == 1 and expected_value_shape[-1] != 1:
                    value = np.squeeze(value, axis=-1)
                if value.shape != expected_value_shape:
                    raise ValueShapeError(expected_value_shape, value.shape)
        else:
            expected_value_shape = (1,)
            if isinstance(value, list):
                value = np.array(value)
            if isinstance(value, np.ndarray) and value.shape != expected_value_shape:
                raise ValueShapeError(expected_value_shape, value.shape)
    return value


# Traceback (AttributeError)
Traceback (most recent call last):
File "examples/upload_mpi.py", line 52, in <module>
res_ds = out_ds.store(tag)
File "/Hub/hub/compute/transform.py", line 372, in store
n_results = self.store_shard(ds_in_shard, ds_out, start, token=token)
File "/Hub/hub/compute/transform.py", line 288, in store_shard
self.upload(
File "/Hub/hub/compute/transform.py", line 222, in upload
list(self.map(upload_chunk, index_batched_values))
File "/Hub/hub/compute/transform.py", line 212, in upload_chunk
ds[key, i * length : i * length + batch_length] = batch
File "/Hub/hub/api/datasetview.py", line 131, in __setitem__
self.dataset._tensors[subpath][slice_list] = assign_value
File "/Hub/hub/store/dynamic_tensor.py", line 187, in __setitem__
max_shape = value[0].shape
AttributeError: 'float' object has no attribute 'shape'

# Fixed code
def check_value_shape(self, value, slice_):
    """Checks if value can be set to the slice"""
    if None not in self.shape and self.dtype != "O":
        if not all([isinstance(sh, int) for sh in slice_]):
            expected_value_shape = tuple(
                [
                    len(range(*slice_shape.indices(self.shape[i])))
                    for i, slice_shape in enumerate(slice_)
                    if not isinstance(slice_shape, int)
                ]
            )

            if isinstance(value, list):
                value = np.array(value)
            if isinstance(value, np.ndarray):
                value_shape = [dim for dim in value.shape if dim != 1]
                expected_shape = [dim for dim in expected_value_shape if dim != 1]
                if value_shape != expected_shape:
                    raise ValueShapeError(expected_value_shape, value.shape)
                else:
                    value = value.reshape(expected_value_shape)
        else:
            expected_value_shape = (1,)
            if isinstance(value, list):
                value = np.array(value)
            if isinstance(value, np.ndarray) and value.shape != expected_value_shape:
                raise ValueShapeError(expected_value_shape, value.shape)
    return value