# Buggy code
def tile(cls, op):
    check_chunks_unknown_shape(op.inputs, TilesError)
    out = op.outputs[0]
    new_chunk_size = op.chunk_size
    if isinstance(out, DATAFRAME_TYPE):
        itemsize = max(getattr(dt, "itemsize", 8) for dt in out.dtypes)
    else:
        itemsize = out.dtype.itemsize
    steps = plan_rechunks(
        op.inputs[0],
        new_chunk_size,
        itemsize,
        threshold=op.threshold,
        chunk_size_limit=op.chunk_size_limit,
    )
    for c in steps:
        out = compute_rechunk(out.inputs[0], c)

    if op.reassign_worker:
        for c in out.chunks:
            c.op._reassign_worker = True

    return [out]


# Traceback (ValueError)
Traceback (most recent call last):
File "/home/admin/work/_public-mars-0.6.2.zip/mars/scheduler/graph.py", line 410, in _execute_graph
self.prepare_graph(compose=compose)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/utils.py", line 377, in _wrapped
return func(*args, **kwargs)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/utils.py", line 451, in _inner
return func(*args, **kwargs)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/scheduler/graph.py", line 648, in prepare_graph
self._target_tileable_datas + fetch_tileables, tileable_graph)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/utils.py", line 451, in _inner
return func(*args, **kwargs)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tiles.py", line 348, in build
tileables, tileable_graph=tileable_graph)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/utils.py", line 451, in _inner
return func(*args, **kwargs)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tiles.py", line 262, in build
self._on_tile_failure(tileable_data.op, exc_info)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tiles.py", line 301, in inner
raise exc_info[1].with_traceback(exc_info[2]) from None
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tiles.py", line 242, in build
tiled = self._tile(tileable_data, tileable_graph)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tiles.py", line 337, in _tile
return super()._tile(tileable_data, tileable_graph)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tiles.py", line 203, in _tile
tds = on_tile(tileable_data.op.outputs, tds)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/scheduler/graph.py", line 630, in on_tile
return self.context.wraps(handler.dispatch)(first.op)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/context.py", line 72, in h
return func(*args, **kwargs)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/utils.py", line 451, in _inner
return func(*args, **kwargs)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tiles.py", line 119, in dispatch
tiled = op_cls.tile(op)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/learn/contrib/xgboost/dmatrix.py", line 255, in tile
return cls._tile_multi_output(op)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/learn/contrib/xgboost/dmatrix.py", line 139, in _tile_multi_output
label = label.rechunk({0: nsplit})._inplace_tile()
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tensor/rechunk/rechunk.py", line 81, in rechunk
chunk_size = get_nsplits(tensor, chunk_size, tensor.dtype.itemsize)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tensor/rechunk/core.py", line 38, in get_nsplits
return decide_chunk_sizes(tileable.shape, chunk_size, itemsize)
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tensor/utils.py", line 551, in decide_chunk_sizes
return normalize_chunk_sizes(shape, tuple(chunk_size[j] for j in range(len(shape))))
File "/home/admin/work/_public-mars-0.6.2.zip/mars/tensor/utils.py", line 66, in normalize_chunk_sizes
raise ValueError('chunks shape should be of the same length, '
ValueError: chunks shape should be of the same length, got shape: 1000000, chunks: (nan,)

# Fixed code
def tile(cls, op):
    check_chunks_unknown_shape(op.inputs, TilesError)

    a = op.input
    a = asdataframe(a) if a.ndim == 2 else asseries(a)
    chunk_size = _get_chunk_size(a, op.chunk_size)
    if chunk_size == a.nsplits:
        return [a]

    out = op.outputs[0]
    new_chunk_size = chunk_size
    if isinstance(out, DATAFRAME_TYPE):
        itemsize = max(getattr(dt, "itemsize", 8) for dt in out.dtypes)
    else:
        itemsize = out.dtype.itemsize
    steps = plan_rechunks(
        op.inputs[0],
        new_chunk_size,
        itemsize,
        threshold=op.threshold,
        chunk_size_limit=op.chunk_size_limit,
    )
    for c in steps:
        out = compute_rechunk(out.inputs[0], c)

    if op.reassign_worker:
        for c in out.chunks:
            c.op._reassign_worker = True

    return [out]