code: def to_dmatrix(
      data,
      label=None,
      missing=None,
      weight=None,
      base_margin=None,
      feature_names=None,
      feature_types=None,
  ):
      data = check_data(data)
      label = check_array_like(label, "label")
      weight = check_array_like(weight, "weight")
      base_margin = check_array_like(base_margin, "base_margin")
  
      # If not multiple outputs, try to collect the chunks on same worker into one
      # to feed the data into XGBoost for training.
      op = ToDMatrix(
          data=data,
          label=label,
          missing=missing,
          weight=weight,
          base_margin=base_margin,
          feature_names=feature_names,
          feature_types=feature_types,
          gpu=data.op.gpu,
          _output_types=get_output_types(data),
      )
      return op()
  
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 3 for calling a global function with example usage: to_dmatrix(data, label, missing, weight, base_margin, feature_names, feature_types) and returns: op