code: def execute(cls, ctx: Union[dict, Context], op: "ToDMatrix"):
      if op._collocate:
          outs = op.outputs
          ctx[outs[0].key] = ctx[op.inputs[0].key]
          has_label = False
          if op.label is not None:
              has_label = True
              ctx[outs[1].key] = ctx[op.inputs[1].key]
          if op.weight is not None:
              i_weight = 1 if not has_label else 2
              ctx[outs[i_weight].key] = ctx[op.inputs[i_weight].key]
          if op.base_margin is not None:
              ctx[outs[-1].key] = ctx[op.inputs[-1].key]
      else:
          out = op.outputs[0]
          data = cls._from_ctx_if_not_none(ctx, op.data)
          if data is None:
              data = np.empty((0, out.shape[1]))
          ctx[out.key] = (
              data,
              cls._from_ctx_if_not_none(ctx, op.label),
              cls._from_ctx_if_not_none(ctx, op.weight),
              cls._from_ctx_if_not_none(ctx, op.base_margin),
              op.missing,
              op.feature_names,
              op.feature_types,
          )
  
imports: import itertools
  from typing import List, Union
  import numpy
  from ....None import opcodes
  from ....core import get_output_types, recursive_tile
  from ....core.context import get_context, Context
  from ....dataframe.core import DATAFRAME_TYPE
  from ....serialization.serializables import KeyField, Float64Field, ListField, BoolField
  from ....tensor.core import TENSOR_TYPE, TENSOR_CHUNK_TYPE
  from ....tensor import tensor
  from ....typing import TileableType, ChunkType
  from ....utils import has_unknown_shape, ensure_own_data, build_fetch
  from ...operands import LearnOperand, LearnOperandMixin
  from ...utils import convert_to_tensor_or_dataframe, concat_chunks
label_desc: Use image node_id 10 for calling the ToDMatrix obj's underlying member method code with example usage: obj.execute(cls, ctx, op) without return types