code: def tile(cls, op: "TensorInsert"):
      inp = op.inputs[0]
      axis = op.axis
      if axis is None:
          inp = yield from recursive_tile(inp.flatten())
          axis = 0
      else:
          new_splits = [
              s if i == axis else sum(s)
              for i, s in enumerate(inp.nsplits)
          ]
          inp = yield from recursive_tile(inp.rechunk(new_splits))
  
      if has_unknown_shape(inp):
          yield
  
      index_obj = op.index_obj
      values = op.values
      if isinstance(values, ENTITY_TYPE):
          # if values is Mars type, we rechunk it into one chunk and
          # all insert chunks depend on it
          values = yield from recursive_tile(
              values.rechunk(values.shape)
          )
  
      nsplits_on_axis = []
      if isinstance(index_obj, int):
          splits = inp.nsplits[axis]
          cum_splits = np.cumsum([0] + list(splits))
          # add 1 for last split
          cum_splits[-1] = cum_splits[-1] + 1
          in_idx = cum_splits.searchsorted(index_obj, side="right") - 1
          out_chunks = []
          for chunk in inp.chunks:
              if chunk.index[axis] == in_idx:
                  chunk_op = op.copy().reset_key()
                  chunk_op._index_obj = index_obj - cum_splits[in_idx]
                  if isinstance(values, ENTITY_TYPE):
                      chunk_values = values.chunks[0]
                  else:
                      chunk_values = values
                  inputs = filter_inputs([chunk, chunk_values])
                  shape = tuple(
                      s + calc_object_length(index_obj)
                      if i == axis
                      else s
                      for i, s in enumerate(chunk.shape)
                  )
                  out_chunks.append(
                      chunk_op.new_chunk(
                          inputs, shape=shape, index=chunk.index
                      )
                  )
                  nsplits_on_axis.append(shape[axis])
              else:
                  out_chunks.append(chunk)
                  nsplits_on_axis.append(chunk.shape[axis])
      elif isinstance(index_obj, ENTITY_TYPE):
          index_obj = yield from recursive_tile(
              index_obj.rechunk(index_obj.shape)
          )
          offset = 0
          out_chunks = []
          for chunk in inp.chunks:
              chunk_op = op.copy().reset_key()
              chunk_op._index_obj = index_obj.chunks[0]
              if isinstance(values, ENTITY_TYPE):
                  chunk_values = values.chunks[0]
              else:
                  chunk_values = values
              chunk_op._values = chunk_values
              if chunk.index[axis] + 1 == len(inp.nsplits[axis]):
                  # the last chunk on axis
                  chunk_op._range_on_axis = (
                      offset,
                      offset + chunk.shape[axis] + 1,
                  )
              else:
                  chunk_op._range_on_axis = (
                      offset,
                      offset + chunk.shape[axis],
                  )
              shape = tuple(
                  np.nan if j == axis else s
                  for j, s in enumerate(chunk.shape)
              )
              inputs = filter_inputs(
                  [chunk, index_obj.chunks[0], chunk_values]
              )
              out_chunks.append(
                  chunk_op.new_chunk(
                      inputs, shape=shape, index=chunk.index
                  )
              )
              offset += chunk.shape[axis]
              nsplits_on_axis.append(np.nan)
      else:
          # index object is slice or sequence of ints
          if isinstance(index_obj, slice):
              index_obj = range(
                  index_obj.start or 0,
                  index_obj.stop,
                  index_obj.step or 1,
              )
          splits = inp.nsplits[axis]
          cum_splits = np.cumsum([0] + list(splits))
          # add 1 for last split
          cum_splits[-1] = cum_splits[-1] + 1
          chunk_idx_params = [[[], []] for _ in splits]
          for i, int_idx in enumerate(index_obj):
              in_idx = (
                  cum_splits.searchsorted(int_idx, side="right") - 1
              )
              chunk_idx_params[in_idx][0].append(
                  int_idx - cum_splits[in_idx]
              )
              chunk_idx_params[in_idx][1].append(i)
  
          out_chunks = []
          offset = 0
          for chunk in inp.chunks:
              idx_on_axis = chunk.index[axis]
              if len(chunk_idx_params[idx_on_axis][0]) > 0:
                  chunk_op = op.copy().reset_key()
                  chunk_index_obj = chunk_idx_params[idx_on_axis][0]
                  shape = tuple(
                      s + len(chunk_index_obj) if j == axis else s
                      for j, s in enumerate(chunk.shape)
                  )
                  if isinstance(values, int):
                      chunk_op._index_obj = chunk_index_obj
                      out_chunks.append(
                          chunk_op.new_chunk(
                              [chunk], shape=shape, index=chunk.index
                          )
                      )
                  elif isinstance(values, ENTITY_TYPE):
                      chunk_op._values = values.chunks[0]
                      if chunk.index[axis] + 1 == len(
                          inp.nsplits[axis]
                      ):
                          chunk_op._range_on_axis = (
                              offset,
                              offset + chunk.shape[axis] + 1,
                          )
                      else:
                          chunk_op._range_on_axis = (
                              offset,
                              offset + chunk.shape[axis],
                          )
                      out_chunks.append(
                          chunk_op.new_chunk(
                              [chunk, values.chunks[0]],
                              shape=shape,
                              index=chunk.index,
                          )
                      )
                      offset += chunk.shape[axis]
                  else:
                      chunk_op._index_obj = chunk_index_obj
                      values = np.asarray(values)
                      to_shape = [
                          calc_object_length(
                              index_obj, chunk.shape[axis]
                          )
                      ] + [
                          s
                          for j, s in enumerate(inp.shape)
                          if j != axis
                      ]
                      if all(
                          j == k for j, k in zip(to_shape, values.shape)
                      ):
                          chunk_values = np.asarray(values)[
                              chunk_idx_params[idx_on_axis][1]
                          ]
                          chunk_op._values = chunk_values
                          out_chunks.append(
                              chunk_op.new_chunk(
                                  [chunk],
                                  shape=shape,
                                  index=chunk.index,
                              )
                          )
                      else:
                          out_chunks.append(
                              chunk_op.new_chunk(
                                  [chunk],
                                  shape=shape,
                                  index=chunk.index,
                              )
                          )
  
                  nsplits_on_axis.append(shape[axis])
              else:
                  out_chunks.append(chunk)
                  nsplits_on_axis.append(chunk.shape[axis])
  
      nsplits = tuple(
          s if i != axis else tuple(nsplits_on_axis)
          for i, s in enumerate(inp.nsplits)
      )
      out = op.outputs[0]
      new_op = op.copy()
      return new_op.new_tensors(
          op.inputs,
          shape=out.shape,
          order=out.order,
          chunks=out_chunks,
          nsplits=nsplits,
      )
  
imports: import numpy
  from ...None import opcodes
  from ...core import ENTITY_TYPE, recursive_tile
  from ...serialization.serializables import Int32Field, TupleField, AnyField, KeyField
  from ...utils import has_unknown_shape
  from ..datasource import tensor
  from ..operands import TensorHasInput, TensorOperandMixin
  from ..utils import filter_inputs, validate_axis, calc_object_length
label_desc: Use image node_id 7 for calling the TensorInsert obj's underlying member method code with example usage: obj.tile(cls, op) and returns: new_op