def METHOD_NAME(cls, op):
    from ..merge.stack import TensorStack
    from ..reduction import TensorAll, TensorAny
    ar1, ar2 = op.inputs
    invert = op.invert
    out = op.outputs[0]
    out_chunks = []
    for ar1_chunk in ar1.chunks:
        to_concat_chunks = []
        for ar2_chunk in ar2.chunks:
            chunk_op = op.copy().reset_key()
            out_chunk = chunk_op.new_chunk(
                [ar1_chunk, ar2_chunk],
                dtype=out.dtype,
                shape=ar1_chunk.shape,
                order=out.order,
                index=ar1_chunk.index,
            )
            to_concat_chunks.append(out_chunk)
        if len(to_concat_chunks) == 1:
            out_chunks.append(to_concat_chunks[0])
        else:
            # concat chunks
            concat_op = TensorStack(axis=0)
            shape = (len(to_concat_chunks),) + ar1_chunk.shape
            concat_chunk = concat_op.new_chunk(
                to_concat_chunks, shape=shape, dtype=out.dtype, order=out.order
            )
            if not invert:
                chunk_op = TensorAny(axis=(0,), dtype=out.dtype)
                out_chunk = chunk_op.new_chunk(
                    [concat_chunk],
                    shape=ar1_chunk.shape,
                    dtype=out.dtype,
                    order=out.order,
                    index=ar1_chunk.index,
                )
            else:
                chunk_op = TensorAll(axis=(0,), dtype=out.dtype)
                out_chunk = chunk_op.new_chunk(
                    [concat_chunk],
                    shape=ar1_chunk.shape,
                    dtype=out.dtype,
                    order=out.order,
                    index=ar1_chunk.index,
                )
            out_chunks.append(out_chunk)
    params = out.params.copy()
    params["nsplits"] = ar1.nsplits
    params["chunks"] = out_chunks
    new_op = op.copy()
    return new_op.new_tensors(op.inputs, kws=[params])