code: def __init__(
      self,
      core_context: det.core.Context,
      args: TrainingArguments,
      filter_metrics: Optional[List[str]] = None,
      user_data: Optional[Dict[str, Any]] = None,
  ) -> None:
      super().__init__()
  
      self.core_context = core_context
  
      self.filter_metrics = filter_metrics
      self.user_data = user_data
      self.load_last_checkpoint(args)
  
      self.last_metrics: Dict[str, float] = {
          "train_step": -1,
          "eval_step": -1,
      }
      self.searcher_ops = self.core_context.searcher.operations()
      self.current_op = next(self.searcher_ops)
      self.updating_searcher = False
  
      cluster_info = det.get_cluster_info()
      assert (
          cluster_info
      ), "Could not find `cluster_info`, the HF Callback must be run on a Determined Cluster"
      searcher_config = cluster_info.trial._config["searcher"]
      self.searcher_metric = searcher_config["metric"]
      # Custom searchers have a different config structure which need to be handled differently
      if searcher_config["name"] == "custom":
          self.searcher_unit = "batches"
          self.searcher_max_length = self.current_op.length
      else:
          self.searcher_unit = list(
              searcher_config["max_length"].keys()
          )[0]
          self.searcher_max_length = list(
              searcher_config["max_length"].values()
          )[0]
          self._check_searcher_compatibility(args)
  
imports: import json
  import logging
  import os
  from typing import Any, Dict, List, Optional, Tuple
  from transformers import TrainerCallback, TrainerControl, TrainerState, TrainingArguments
  from transformers.trainer_utils import get_last_checkpoint
  import determined
label_desc: Use image node_id 1 to create a new DetCallback object from inherited base classes: TrainerCallback with example: obj = DetCallback(core_context, args, filter_metrics, user_data)