# Buggy code
def tile(cls, op):
    inputs = op.inputs
    check_chunks_unknown_shape(inputs, TilesError)
    axis_to_nsplits = defaultdict(list)
    has_dataframe = any(
        output_type == OutputType.dataframe for output_type in op.output_types
    )
    for ax in op.axes:
        if has_dataframe and ax == 1:
            # if DataFrame exists, for the columns axis,
            # we only allow 1 chunk to ensure the columns consistent
            axis_to_nsplits[ax].append((inputs[0].shape[ax],))
            continue
        for inp in inputs:
            if ax < inp.ndim:
                axis_to_nsplits[ax].append(inp.nsplits[ax])
    ax_nsplit = {ax: decide_unify_split(*ns) for ax, ns in axis_to_nsplits.items()}
    inputs = [cls._safe_rechunk(inp, ax_nsplit) for inp in inputs]

    mapper_seeds = [None] * len(op.axes)
    reducer_seeds = [None] * len(op.axes)
    for i, ax in enumerate(op.axes):
        rs = np.random.RandomState(op.seeds[i])
        size = len(ax_nsplit[ax])
        if size > 1:
            mapper_seeds[i] = gen_random_seeds(size, rs)
            reducer_seeds[i] = gen_random_seeds(size, rs)
        else:
            mapper_seeds[i] = reducer_seeds[i] = [op.seeds[i]] * size
    out_chunks = []
    out_nsplits = []
    for output_type, inp, oup in zip(op.output_types, inputs, op.outputs):
        inp_axes = tuple(ax for ax in op.axes if ax < inp.ndim)
        reduce_sizes = tuple(inp.chunk_shape[ax] for ax in inp_axes)
        output_types = [output_type]

        if len(inp_axes) == 0:
            continue

        nsplits = list(inp.nsplits)
        for ax in inp_axes:
            cs = len(nsplits[ax])
            if cs > 1:
                nsplits[ax] = (np.nan,) * cs
        out_nsplits.append(tuple(nsplits))

        if all(reduce_size == 1 for reduce_size in reduce_sizes):
            # no need to do shuffle
            chunks = []
            for c in inp.chunks:
                chunk_op = LearnShuffle(
                    axes=inp_axes,
                    seeds=op.seeds[: len(inp_axes)],
                    output_types=output_types,
                )
                params = cls._calc_chunk_params(
                    c, inp_axes, inp.chunk_shape, oup, output_type, chunk_op, True
                )
                out_chunk = chunk_op.new_chunk([c], kws=[params])
                chunks.append(out_chunk)
            out_chunks.append(chunks)
            continue

        if inp.ndim > 1:
            left_chunk_shape = [
                s for ax, s in enumerate(inp.chunk_shape) if ax not in inp_axes
            ]
            idx_iter = itertools.product(*[range(s) for s in left_chunk_shape])
        else:
            idx_iter = [()]
        reduce_chunks = []
        out_chunks.append(reduce_chunks)
        for idx in idx_iter:
            map_chunks = []
            for reducer_inds in itertools.product(*[range(s) for s in reduce_sizes]):
                inp_index = list(idx)
                for ax, reducer_ind in zip(inp_axes, reducer_inds):
                    inp_index.insert(ax, reducer_ind)
                inp_index = tuple(inp_index)
                in_chunk = inp.cix[inp_index]
                params = in_chunk.params
                map_chunk_op = LearnShuffle(
                    stage=OperandStage.map,
                    output_types=output_types,
                    axes=inp_axes,
                    seeds=tuple(
                        mapper_seeds[j][in_chunk.index[ax]]
                        for j, ax in enumerate(inp_axes)
                    ),
                    reduce_sizes=reduce_sizes,
                )
                map_chunk = map_chunk_op.new_chunk([in_chunk], **params)
                map_chunks.append(map_chunk)

            proxy_chunk = LearnShuffleProxy(_tensor_keys=[inp.key]).new_chunk(
                map_chunks
            )

            reduce_axes = tuple(
                ax for j, ax in enumerate(inp_axes) if reduce_sizes[j] > 1
            )
            reduce_sizes_ = tuple(rs for rs in reduce_sizes if rs > 1)
            for c in map_chunks:
                shuffle_key = ",".join(str(idx) for idx in c.index)
                chunk_op = LearnShuffle(
                    stage=OperandStage.reduce,
                    output_types=output_types,
                    axes=reduce_axes,
                    seeds=tuple(
                        reducer_seeds[j][c.index[ax]]
                        for j, ax in enumerate(inp_axes)
                        if reduce_sizes[j] > 1
                    ),
                    reduce_sizes=reduce_sizes_,
                    shuffle_key=shuffle_key,
                )
                params = cls._calc_chunk_params(
                    c, inp_axes, inp.chunk_shape, oup, output_type, chunk_op, False
                )
                reduce_chunk = chunk_op.new_chunk([proxy_chunk], kws=[params])
                reduce_chunks.append(reduce_chunk)

    new_op = op.copy()
    params = [out.params for out in op.outputs]
    if len(out_chunks) < len(op.outputs):
        # axes are all higher than its ndim
        for i, inp in enumerate(op.inputs):
            if all(ax >= inp.ndim for ax in op.axes):
                out_chunks.insert(i, inp.chunks)
                out_nsplits.insert(i, inp.nsplits)
        assert len(out_chunks) == len(op.outputs)
    for i, param, chunks, ns in zip(itertools.count(), params, out_chunks, out_nsplits):
        param["chunks"] = chunks
        param["nsplits"] = ns
        param["_position_"] = i
    return new_op.new_tileables(op.inputs, kws=params)


# Traceback (KeyError)
SCH 2021-01-26 14:35:13,477 Mars Scheduler started in standalone mode.
SCH 2021-01-26 14:35:13,477 Actor s:h1:SchedulerClusterInfoActor running in process 72974
SCH 2021-01-26 14:35:13,478 Actor s:h1:ChunkMetaActor running in process 72974 at 127.0.0.1:27341
SCH 2021-01-26 14:35:13,478 Actor s:h1:SessionManagerActor running in process 72974
SCH 2021-01-26 14:35:13,478 Actor s:h1:ResourceActor running in process 72974
SCH 2021-01-26 14:35:13,479 Actor s:h1:NodeInfoActor running in process 72974
WOR1 2021-01-26 14:35:13,484 Setting soft limit to 12.80G.
WOR0 2021-01-26 14:35:13,484 Setting soft limit to 12.80G.
../src/plasma/store.cc:../src/plasma/store.cc1274: Allowing the Plasma store to use up to 0.0104858GB of memory.
:../src/plasma/store.cc:1274: 1297Allowing the Plasma store to use up to : Starting object store with directory /tmp and huge page support disabled
0.0104858GB of memory.
../src/plasma/store.cc:1297: Starting object store with directory /tmp and huge page support disabled
WOR1 2021-01-26 14:35:13,650 Actor w:0:WorkerClusterInfoActor running in process 72983
WOR0 2021-01-26 14:35:13,650 Actor w:0:WorkerClusterInfoActor running in process 72984
WOR0 2021-01-26 14:35:13,654 Actor w:0:WorkerDaemonActor running in process 72984
WOR1 2021-01-26 14:35:13,654 Actor w:0:WorkerDaemonActor running in process 72983
WOR1 2021-01-26 14:35:13,669 Actor w:0:StatusActor running in process 72983
WOR0 2021-01-26 14:35:13,669 Actor w:0:StatusActor running in process 72984
WOR0 2021-01-26 14:35:13,671 Actor w:0:StatusReporterActor running in process 72984
WOR1 2021-01-26 14:35:13,672 Actor w:0:StatusReporterActor running in process 72983
WOR0 2021-01-26 14:35:13,674 Actor w:0:MemQuotaActor running in process 72984
WOR1 2021-01-26 14:35:13,674 Actor w:0:MemQuotaActor running in process 72983
WOR0 2021-01-26 14:35:13,676 Actor w:0:StorageManagerActor running in process 72984
WOR1 2021-01-26 14:35:13,676 Actor w:0:StorageManagerActor running in process 72983
WOR0 2021-01-26 14:35:13,678 Actor w:0:SharedHolderActor running in process 72984
WOR1 2021-01-26 14:35:13,678 Actor w:0:SharedHolderActor running in process 72983
WOR1 2021-01-26 14:35:13,696 Detected actual plasma store size: 10.00M
WOR1 2021-01-26 14:35:13,697 Actor w:0:DispatchActor running in process 72983
WOR0 2021-01-26 14:35:13,697 Detected actual plasma store size: 10.00M
WOR0 2021-01-26 14:35:13,699 Actor w:0:DispatchActor running in process 72984
WOR1 2021-01-26 14:35:13,699 Actor w:0:EventsActor running in process 72983
WOR1 2021-01-26 14:35:13,700 Actor w:0:ReceiverManagerActor running in process 72983
WOR0 2021-01-26 14:35:13,701 Actor w:0:EventsActor running in process 72984
WOR0 2021-01-26 14:35:13,703 Actor w:0:ReceiverManagerActor running in process 72984
WOR1 2021-01-26 14:35:13,703 Actor w:0:ExecutionActor running in process 72983
WOR0 2021-01-26 14:35:13,706 Actor w:0:ExecutionActor running in process 72984
WOR1 2021-01-26 14:35:13,711 Actor w:1:mars-cpu-calc running in process 72986
WOR0 2021-01-26 14:35:13,713 Actor w:1:mars-cpu-calc running in process 72985
WOR1 2021-01-26 14:35:13,722 Slot w:1:mars-cpu-calc registered for queue cpu on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,723 Slot w:1:mars-cpu-calc registered for queue cpu on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,726 Actor w:1:mars-inproc-holder running in process 72986
WOR0 2021-01-26 14:35:13,726 Actor w:1:mars-inproc-holder running in process 72985
WOR1 2021-01-26 14:35:13,732 Actor w:1:io_runner_inproc running in process 72986
WOR0 2021-01-26 14:35:13,732 Actor w:1:io_runner_inproc running in process 72985
WOR1 2021-01-26 14:35:13,735 Actor w:2:mars-cpu-calc running in process 72988
WOR0 2021-01-26 14:35:13,738 Actor w:2:mars-cpu-calc running in process 72987
WOR1 2021-01-26 14:35:13,752 Slot w:2:mars-cpu-calc registered for queue cpu on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,754 Slot w:2:mars-cpu-calc registered for queue cpu on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,760 Actor w:2:mars-inproc-holder running in process 72988
WOR0 2021-01-26 14:35:13,761 Actor w:2:mars-inproc-holder running in process 72987
WOR1 2021-01-26 14:35:13,767 Actor w:2:io_runner_inproc running in process 72988
WOR0 2021-01-26 14:35:13,768 Actor w:2:io_runner_inproc running in process 72987
WOR1 2021-01-26 14:35:13,773 Actor w:3:mars-sender-0 running in process 72989
WOR0 2021-01-26 14:35:13,776 Actor w:3:mars-sender-0 running in process 72990
WOR0 2021-01-26 14:35:13,795 Slot w:3:mars-sender-0 registered for queue sender on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,795 Slot w:3:mars-sender-0 registered for queue sender on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,799 Actor w:4:mars-sender-1 running in process 72991
WOR1 2021-01-26 14:35:13,800 Actor w:4:mars-sender-1 running in process 72992
WOR0 2021-01-26 14:35:13,814 Slot w:4:mars-sender-1 registered for queue sender on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,815 Slot w:4:mars-sender-1 registered for queue sender on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,818 Actor w:5:mars-sender-2 running in process 72993
WOR1 2021-01-26 14:35:13,819 Actor w:5:mars-sender-2 running in process 72994
WOR0 2021-01-26 14:35:13,834 Slot w:5:mars-sender-2 registered for queue sender on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,835 Slot w:5:mars-sender-2 registered for queue sender on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,838 Actor w:6:mars-sender-3 running in process 72996
WOR1 2021-01-26 14:35:13,841 Actor w:6:mars-sender-3 running in process 72995
WOR0 2021-01-26 14:35:13,854 Slot w:6:mars-sender-3 registered for queue sender on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,855 Slot w:6:mars-sender-3 registered for queue sender on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,857 Slot w:3:mars-custom-log-fetch registered for queue custom_log on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,858 Slot w:3:mars-custom-log-fetch registered for queue custom_log on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,861 Slot w:4:mars-custom-log-fetch registered for queue custom_log on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,863 Slot w:4:mars-custom-log-fetch registered for queue custom_log on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,864 Slot w:5:mars-custom-log-fetch registered for queue custom_log on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,865 Slot w:5:mars-custom-log-fetch registered for queue custom_log on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,867 Slot w:6:mars-custom-log-fetch registered for queue custom_log on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,868 Slot w:6:mars-custom-log-fetch registered for queue custom_log on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,869 Actor w:3:mars-receiver-0 running in process 72990
WOR1 2021-01-26 14:35:13,870 Actor w:3:mars-receiver-0 running in process 72989
WOR0 2021-01-26 14:35:13,873 Slot w:3:mars-receiver-0 registered for queue receiver on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,873 Slot w:3:mars-receiver-0 registered for queue receiver on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,875 Actor w:3:mars-receiver-1 running in process 72990
WOR1 2021-01-26 14:35:13,875 Actor w:3:mars-receiver-1 running in process 72989
WOR0 2021-01-26 14:35:13,878 Slot w:3:mars-receiver-1 registered for queue receiver on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,878 Slot w:3:mars-receiver-1 registered for queue receiver on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,879 Actor w:4:mars-receiver-2 running in process 72991
WOR1 2021-01-26 14:35:13,880 Actor w:4:mars-receiver-2 running in process 72992
WOR0 2021-01-26 14:35:13,883 Slot w:4:mars-receiver-2 registered for queue receiver on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,884 Slot w:4:mars-receiver-2 registered for queue receiver on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,885 Actor w:4:mars-receiver-3 running in process 72991
WOR1 2021-01-26 14:35:13,885 Actor w:4:mars-receiver-3 running in process 72992
WOR0 2021-01-26 14:35:13,887 Slot w:4:mars-receiver-3 registered for queue receiver on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,888 Slot w:4:mars-receiver-3 registered for queue receiver on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,889 Actor w:5:mars-receiver-4 running in process 72993
WOR1 2021-01-26 14:35:13,890 Actor w:5:mars-receiver-4 running in process 72994
WOR0 2021-01-26 14:35:13,892 Slot w:5:mars-receiver-4 registered for queue receiver on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,893 Slot w:5:mars-receiver-4 registered for queue receiver on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,894 Actor w:5:mars-receiver-5 running in process 72993
WOR1 2021-01-26 14:35:13,895 Actor w:5:mars-receiver-5 running in process 72994
WOR0 2021-01-26 14:35:13,897 Slot w:5:mars-receiver-5 registered for queue receiver on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,898 Slot w:5:mars-receiver-5 registered for queue receiver on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,899 Actor w:6:mars-receiver-6 running in process 72996
WOR1 2021-01-26 14:35:13,899 Actor w:6:mars-receiver-6 running in process 72995
WOR0 2021-01-26 14:35:13,902 Slot w:6:mars-receiver-6 registered for queue receiver on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,903 Slot w:6:mars-receiver-6 registered for queue receiver on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,904 Actor w:6:mars-receiver-7 running in process 72996
WOR1 2021-01-26 14:35:13,904 Actor w:6:mars-receiver-7 running in process 72995
WOR0 2021-01-26 14:35:13,908 Slot w:6:mars-receiver-7 registered for queue receiver on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,908 Slot w:6:mars-receiver-7 registered for queue receiver on 127.0.0.1:58971
WOR1 2021-01-26 14:35:13,910 Actor w:0:mars-process-helper running in process 72983
WOR0 2021-01-26 14:35:13,910 Actor w:0:mars-process-helper running in process 72984
WOR1 2021-01-26 14:35:13,911 Slot w:0:mars-process-helper registered for queue process_helper on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,911 Slot w:0:mars-process-helper registered for queue process_helper on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,912 Actor w:1:mars-process-helper running in process 72986
WOR0 2021-01-26 14:35:13,913 Actor w:1:mars-process-helper running in process 72985
WOR0 2021-01-26 14:35:13,915 Slot w:1:mars-process-helper registered for queue process_helper on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,915 Slot w:1:mars-process-helper registered for queue process_helper on 127.0.0.1:58971
WOR1 2021-01-26 14:35:13,918 Actor w:2:mars-process-helper running in process 72988
WOR0 2021-01-26 14:35:13,918 Actor w:2:mars-process-helper running in process 72987
WOR0 2021-01-26 14:35:13,921 Slot w:2:mars-process-helper registered for queue process_helper on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,921 Slot w:2:mars-process-helper registered for queue process_helper on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,924 Actor w:3:mars-process-helper running in process 72990
WOR1 2021-01-26 14:35:13,924 Actor w:3:mars-process-helper running in process 72989
WOR0 2021-01-26 14:35:13,926 Slot w:3:mars-process-helper registered for queue process_helper on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,926 Slot w:3:mars-process-helper registered for queue process_helper on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,930 Actor w:4:mars-process-helper running in process 72991
WOR1 2021-01-26 14:35:13,930 Actor w:4:mars-process-helper running in process 72992
WOR0 2021-01-26 14:35:13,937 Slot w:4:mars-process-helper registered for queue process_helper on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,939 Slot w:4:mars-process-helper registered for queue process_helper on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,944 Actor w:5:mars-process-helper running in process 72993
WOR1 2021-01-26 14:35:13,945 Actor w:5:mars-process-helper running in process 72994
WOR0 2021-01-26 14:35:13,947 Slot w:5:mars-process-helper registered for queue process_helper on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,949 Slot w:5:mars-process-helper registered for queue process_helper on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,954 Actor w:6:mars-process-helper running in process 72996
WOR1 2021-01-26 14:35:13,954 Actor w:6:mars-process-helper running in process 72995
WOR0 2021-01-26 14:35:13,958 Slot w:6:mars-process-helper registered for queue process_helper on 127.0.0.1:49412
WOR1 2021-01-26 14:35:13,959 Slot w:6:mars-process-helper registered for queue process_helper on 127.0.0.1:58971
WOR0 2021-01-26 14:35:13,961 Actor w:0:ResultSenderActor running in process 72984
WOR1 2021-01-26 14:35:13,962 Actor w:0:ResultSenderActor running in process 72983
WOR0 2021-01-26 14:35:13,963 Actor w:0:ResultCopyActor running in process 72984
WOR1 2021-01-26 14:35:13,964 Actor w:0:ResultCopyActor running in process 72983
WARNING:bokeh.server.util:Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. Use non-wildcard values to restrict access explicitly
WEB 2021-01-26 14:35:20,232 Mars UI started at 127.0.0.1:21288
SCH 2021-01-26 14:35:20,874 Actor s:h1:session$b5582d85e3fdfe2b0538c3f4a6751fb5 running in process 72974
SCH 2021-01-26 14:35:20,875 Actor s:h1:assigner$b5582d85e3fdfe2b0538c3f4a6751fb5 running in process 72974
SCH 2021-01-26 14:35:20,875 Actor s:0:AssignEvaluationActor$b5582d85e3fdfe2b0538c3f4a6751fb5 running in process 72974
SCH 2021-01-26 14:35:20,929 Actor s:0:graph$b5582d85e3fdfe2b0538c3f4a6751fb5$9bb221d1340d2ccc125c01ed42330c23 running in process 72974
SCH 2021-01-26 14:35:20,930 Graph 9bb221d1340d2ccc125c01ed42330c23 state from GraphState.UNSCHEDULED to GraphState.PREPARING.
SCH 2021-01-26 14:35:20,946 Begin preparing graph 9bb221d1340d2ccc125c01ed42330c23 with 9 tileables to chunk graph.
SCH 2021-01-26 14:35:20,968 Terminal chunk keys: {'ef47ef4796e60445c544df4932449c98', 'e5d3a577f04edd5ed13e4d1bbedd6835', '5aef6cf6563ec183673159b483273a69', '965705674a7b15205fbe9f303957fe2a', '113cf9a2d1747ee1d168588b6416755f', 'e319d64c44060fb66e67d1c6770d43f9'}
SCH 2021-01-26 14:35:20,971 Placing initial chunks for graph 9bb221d1340d2ccc125c01ed42330c23
SCH 2021-01-26 14:35:20,972 Worker assign quotas: {'127.0.0.1:49412': 1, '127.0.0.1:58971': 1}
SCH 2021-01-26 14:35:20,972 Scan spread ranges: {}
SCH 2021-01-26 14:35:20,973 Creating operand actors for graph 9bb221d1340d2ccc125c01ed42330c23
SCH 2021-01-26 14:35:20,979 Operand actor creation progress: 1 / 18
SCH 2021-01-26 14:35:20,982 Operand actor creation progress: 2 / 18
SCH 2021-01-26 14:35:20,983 Unexpected exception occurred in GraphActor.get_executable_operand_dag. op_key=241a38623560db72c868622ae4cf87da
Traceback (most recent call last):
File "~/Code/mars/mars/scheduler/graph.py", line 830, in get_executable_operand_dag
inp_chunk = input_mapping[(inp.key, inp.id)]
KeyError: ('8501fa868db396f18599c9990f1f1c2a', '140271835165984')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "~/Code/mars/mars/utils.py", line 383, in _wrapped
return func(*args, **kwargs)
File "~/Code/mars/mars/scheduler/graph.py", line 833, in get_executable_operand_dag
= build_fetch_chunk(inp, input_chunk_keys).data
File "~/Code/mars/mars/utils.py", line 581, in build_fetch_chunk
op = chunk_op.get_fetch_op_cls(chunk)(to_fetch_keys=to_fetch_keys, to_fetch_idxes=to_fetch_idxes)
File "~/Code/mars/mars/operands.py", line 551, in _inner
return cls(output_types=output_types, **kw)
TypeError: 'NoneType' object is not callable
Traceback (most recent call last):
File "~/Code/mars/mars/scheduler/graph.py", line 830, in get_executable_operand_dag
inp_chunk = input_mapping[(inp.key, inp.id)]
KeyError: ('8501fa868db396f18599c9990f1f1c2a', '140271835165984')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "~/miniconda3/lib/python3.8/site-packages/gevent/threadpool.py", line 167, in __run_task
thread_result.set(func(*args, **kwargs))
File "mars/actors/pool/gevent_pool.pyx", line 171, in mars.actors.pool.gevent_pool.GeventThreadPool._wrap_watch_sem.inner
File "~/Code/mars/mars/utils.py", line 383, in _wrapped
return func(*args, **kwargs)
File "~/Code/mars/mars/scheduler/graph.py", line 833, in get_executable_operand_dag
= build_fetch_chunk(inp, input_chunk_keys).data
File "~/Code/mars/mars/utils.py", line 581, in build_fetch_chunk
op = chunk_op.get_fetch_op_cls(chunk)(to_fetch_keys=to_fetch_keys, to_fetch_idxes=to_fetch_idxes)
File "~/Code/mars/mars/operands.py", line 551, in _inner
return cls(output_types=output_types, **kw)
TypeError: 'NoneType' object is not callable
2021-01-26T06:35:20Z (<ThreadPoolWorker at 0x7f939500b930 thread_ident=0x700007417000 threadpool-hub=<Hub at 0x7f9394dbad00 thread_ident=0x119739dc0>>, <cyfunction GeventThreadPool._wrap_watch_sem.<locals>.inner at 0x7f9394ea2790>) failed with TypeError

# Fixed code
def tile(cls, op):
    inputs = op.inputs
    check_chunks_unknown_shape(inputs, TilesError)
    axis_to_nsplits = defaultdict(list)
    has_dataframe = any(
        output_type == OutputType.dataframe for output_type in op.output_types
    )
    for ax in op.axes:
        if has_dataframe and ax == 1:
            # if DataFrame exists, for the columns axis,
            # we only allow 1 chunk to ensure the columns consistent
            axis_to_nsplits[ax].append((inputs[0].shape[ax],))
            continue
        for inp in inputs:
            if ax < inp.ndim:
                axis_to_nsplits[ax].append(inp.nsplits[ax])
    ax_nsplit = {ax: decide_unify_split(*ns) for ax, ns in axis_to_nsplits.items()}
    inputs = [cls._safe_rechunk(inp, ax_nsplit) for inp in inputs]

    mapper_seeds = [None] * len(op.axes)
    reducer_seeds = [None] * len(op.axes)
    for i, ax in enumerate(op.axes):
        rs = np.random.RandomState(op.seeds[i])
        size = len(ax_nsplit[ax])
        if size > 1:
            mapper_seeds[i] = gen_random_seeds(size, rs)
            reducer_seeds[i] = gen_random_seeds(size, rs)
        else:
            mapper_seeds[i] = reducer_seeds[i] = [op.seeds[i]] * size
    out_chunks = []
    out_nsplits = []
    for output_type, inp, oup in zip(op.output_types, inputs, op.outputs):
        inp_axes = tuple(ax for ax in op.axes if ax < inp.ndim)
        reduce_sizes = tuple(inp.chunk_shape[ax] for ax in inp_axes)
        output_types = [output_type]

        if len(inp_axes) == 0:
            continue

        nsplits = list(inp.nsplits)
        for ax in inp_axes:
            cs = len(nsplits[ax])
            if cs > 1:
                nsplits[ax] = (np.nan,) * cs
        out_nsplits.append(tuple(nsplits))

        if all(reduce_size == 1 for reduce_size in reduce_sizes):
            # no need to do shuffle
            chunks = []
            for c in inp.chunks:
                chunk_op = LearnShuffle(
                    axes=inp_axes,
                    seeds=op.seeds[: len(inp_axes)],
                    output_types=output_types,
                )
                params = cls._calc_chunk_params(
                    c, inp_axes, inp.chunk_shape, oup, output_type, chunk_op, True
                )
                out_chunk = chunk_op.new_chunk([c], kws=[params])
                chunks.append(out_chunk)
            out_chunks.append(chunks)
            continue

        if inp.ndim > 1:
            left_chunk_shape = [
                s for ax, s in enumerate(inp.chunk_shape) if ax not in inp_axes
            ]
            idx_iter = itertools.product(*[range(s) for s in left_chunk_shape])
        else:
            idx_iter = [()]
        reduce_chunks = []
        out_chunks.append(reduce_chunks)
        for idx in idx_iter:
            map_chunks = []
            for reducer_inds in itertools.product(*[range(s) for s in reduce_sizes]):
                inp_index = list(idx)
                for ax, reducer_ind in zip(inp_axes, reducer_inds):
                    inp_index.insert(ax, reducer_ind)
                inp_index = tuple(inp_index)
                in_chunk = inp.cix[inp_index]
                params = in_chunk.params
                map_chunk_op = LearnShuffle(
                    stage=OperandStage.map,
                    output_types=output_types,
                    axes=inp_axes,
                    seeds=tuple(
                        mapper_seeds[j][in_chunk.index[ax]]
                        for j, ax in enumerate(inp_axes)
                    ),
                    reduce_sizes=reduce_sizes,
                )
                map_chunk = map_chunk_op.new_chunk([in_chunk], **params)
                map_chunks.append(map_chunk)

            proxy_chunk = LearnShuffleProxy(
                _tensor_keys=[inp.key], output_types=[output_type]
            ).new_chunk(map_chunks)

            reduce_axes = tuple(
                ax for j, ax in enumerate(inp_axes) if reduce_sizes[j] > 1
            )
            reduce_sizes_ = tuple(rs for rs in reduce_sizes if rs > 1)
            for c in map_chunks:
                shuffle_key = ",".join(str(idx) for idx in c.index)
                chunk_op = LearnShuffle(
                    stage=OperandStage.reduce,
                    output_types=output_types,
                    axes=reduce_axes,
                    seeds=tuple(
                        reducer_seeds[j][c.index[ax]]
                        for j, ax in enumerate(inp_axes)
                        if reduce_sizes[j] > 1
                    ),
                    reduce_sizes=reduce_sizes_,
                    shuffle_key=shuffle_key,
                )
                params = cls._calc_chunk_params(
                    c, inp_axes, inp.chunk_shape, oup, output_type, chunk_op, False
                )
                reduce_chunk = chunk_op.new_chunk([proxy_chunk], kws=[params])
                reduce_chunks.append(reduce_chunk)

    new_op = op.copy()
    params = [out.params for out in op.outputs]
    if len(out_chunks) < len(op.outputs):
        # axes are all higher than its ndim
        for i, inp in enumerate(op.inputs):
            if all(ax >= inp.ndim for ax in op.axes):
                out_chunks.insert(i, inp.chunks)
                out_nsplits.insert(i, inp.nsplits)
        assert len(out_chunks) == len(op.outputs)
    for i, param, chunks, ns in zip(itertools.count(), params, out_chunks, out_nsplits):
        param["chunks"] = chunks
        param["nsplits"] = ns
        param["_position_"] = i
    return new_op.new_tileables(op.inputs, kws=params)