code: def train(params, dtrain, evals=(), **kwargs):
      """
      Train XGBoost model in Mars manner.
  
      Parameters
      ----------
      Parameters are the same as `xgboost.train`.
  
      Returns
      -------
      results: Booster
      """
  
      evals_result = kwargs.pop("evals_result", dict())
      session = kwargs.pop("session", None)
      run_kwargs = kwargs.pop("run_kwargs", dict())
  
      processed_evals = []
      if evals:
          for eval_dmatrix, name in evals:
              if not isinstance(name, str):
                  raise TypeError(
                      "evals must a list of pairs (DMatrix, string)"
                  )
              if hasattr(eval_dmatrix, "op") and isinstance(
                  eval_dmatrix.op, ToDMatrix
              ):
                  processed_evals.append((eval_dmatrix, name))
              else:
                  processed_evals.append(
                      (to_dmatrix(eval_dmatrix), name)
                  )
  
      op = XGBTrain(
          params=params,
          dtrain=dtrain,
          evals=processed_evals,
          kwargs=kwargs,
      )
      t = op()
      ret = t.execute(session=session, **run_kwargs).fetch(
          session=session
      )
      evals_result.update(ret["history"])
      bst = pickle.loads(ret["booster"])
      num_class = params.get("num_class")
      if num_class:
          bst.set_attr(num_class=str(num_class))
      return bst
  
imports: import itertools
  import logging
  import pickle
  from collections import OrderedDict, defaultdict
  import numpy
  from ....None import opcodes
  from ....core import OutputType
  from ....core.context import get_context
  from ....core.operand import MergeDictOperand
  from ....serialization.serializables import FieldTypes, DictField, KeyField, ListField
  from ....utils import ensure_own_data
  from .dmatrix import ToDMatrix, to_dmatrix
  from .start_tracker import StartTracker
label_desc: Use image node_id 2 for calling a global function with example usage: train(params, dtrain, evals) and returns: bst