code: def _eval_function_wrapper(func):
      
      def inner(preds, dataset):
          """Call passed function with appropriate arguments."""
          labels = dataset.get_label()
          argc = argc_(func)
          if argc == 2:
              return func(labels, preds)
          elif argc == 3:
              return func(labels, preds, dataset.get_weight())
          elif argc == 4:
              return func(labels, preds, dataset.get_weight(), dataset.get_group())
          else:
              raise TypeError("Self-defined eval function should have 2, 3 or 4 arguments, got %d" % argc)
      return inner
docs: Decorate an eval function.
  
      Note
      ----
      For multi-class task, the y_pred is group by class_id first, then group by row_id.
      If you want to get i-th row y_pred in j-th class, the access way is y_pred[j * num_data + i].
  
      Parameters
      ----------
      func : callable
          Expects a callable with following signatures:
          ``func(y_true, y_pred)``,
          ``func(y_true, y_pred, weight)``
          or ``func(y_true, y_pred, weight, group)``
          and returns (eval_name->string, eval_result->float, is_bigger_better->bool):
  
              y_true : array-like of shape = [n_samples]
                  The target values.
              y_pred : array-like of shape = [n_samples] or shape = [n_samples * n_classes] (for multi-class task)
                  The predicted values.
              weight : array-like of shape = [n_samples]
                  The weight of samples.
              group : array-like
                  Group/query data, used for ranking task.
  
      Returns
      -------
      new_func : callable
          The new eval function as expected by ``lightgbm.engine.train``.
          The signature is ``new_func(preds, dataset)``:
  
              preds : array-like of shape = [n_samples] or shape = [n_samples * n_classes] (for multi-class task)
                  The predicted values.
              dataset : Dataset
                  The training set from which the labels will be extracted using ``dataset.get_label()``.