class_docstr: Internal early stopping callable class.
class_docstr_tok: ["Internal","early","stopping","callable","class","."]
code: def _init(self, env: CallbackEnv) -> None:
      if (
          env.evaluation_result_list is None
          or env.evaluation_result_list == []
      ):
          raise ValueError(
              "For early stopping, at least one dataset and eval metric is required for evaluation"
          )
  
      is_dart = any(
          env.params.get(alias, "") == "dart"
          for alias in _ConfigAliases.get("boosting")
      )
      if is_dart:
          self.enabled = False
          _log_warning("Early stopping is not available in dart mode")
          return
  
      # validation sets are guaranteed to not be identical to the training data in cv()
      if isinstance(env.model, Booster):
          only_train_set = len(
              env.evaluation_result_list
          ) == 1 and self._is_train_set(
              ds_name=env.evaluation_result_list[0][0],
              eval_name=env.evaluation_result_list[0][1].split(" ")[0],
              env=env,
          )
          if only_train_set:
              self.enabled = False
              _log_warning(
                  "Only training set found, disabling early stopping."
              )
              return
  
      if self.verbose:
          _log_info(
              f"Training until validation scores don't improve for {self.stopping_rounds} rounds"
          )
  
      self._reset_storages()
  
      n_metrics = len({m[1] for m in env.evaluation_result_list})
      n_datasets = len(env.evaluation_result_list) // n_metrics
      if isinstance(self.min_delta, list):
          if not all(t >= 0 for t in self.min_delta):
              raise ValueError(
                  "Values for early stopping min_delta must be non-negative."
              )
          if len(self.min_delta) == 0:
              if self.verbose:
                  _log_info("Disabling min_delta for early stopping.")
              deltas = [0.0] * n_datasets * n_metrics
          elif len(self.min_delta) == 1:
              if self.verbose:
                  _log_info(
                      f"Using {self.min_delta[0]} as min_delta for all metrics."
                  )
              deltas = self.min_delta * n_datasets * n_metrics
          else:
              if len(self.min_delta) != n_metrics:
                  raise ValueError(
                      "Must provide a single value for min_delta or as many as metrics."
                  )
              if self.first_metric_only and self.verbose:
                  _log_info(
                      f"Using only {self.min_delta[0]} as early stopping min_delta."
                  )
              deltas = self.min_delta * n_datasets
      else:
          if self.min_delta < 0:
              raise ValueError(
                  "Early stopping min_delta must be non-negative."
              )
          if (
              self.min_delta > 0
              and n_metrics > 1
              and not self.first_metric_only
              and self.verbose
          ):
              _log_info(
                  f"Using {self.min_delta} as min_delta for all metrics."
              )
          deltas = [self.min_delta] * n_datasets * n_metrics
  
      # split is needed for "<dataset type> <metric>" case (e.g. "train l1")
      self.first_metric = env.evaluation_result_list[0][1].split(" ")[
          -1
      ]
      for eval_ret, delta in zip(env.evaluation_result_list, deltas):
          self.best_iter.append(0)
          if eval_ret[3]:  # greater is better
              self.best_score.append(float("-inf"))
              self.cmp_op.append(partial(self._gt_delta, delta=delta))
          else:
              self.best_score.append(float("inf"))
              self.cmp_op.append(partial(self._lt_delta, delta=delta))
  
imports: from collections import OrderedDict
  from dataclasses import dataclass
  from functools import partial
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
  from .basic import Booster, _ConfigAliases, _LGBM_BoosterEvalMethodResultType, _LGBM_BoosterEvalMethodResultWithStandardDeviationType, _log_info, _log_warning
label_desc: Use image node_id 6 for calling the _EarlyStoppingCallback obj's underlying member method code with example usage: obj._init(env) without return types