code: def on_save(
      self,
      args: TrainingArguments,
      state: TrainerState,
      control: TrainerControl,
      **kwargs: Any,
  ) -> None:
      info = det.get_cluster_info()
      assert info
  
      # local_path is where HF Trainer saves model and tokenizer in a given step.
      local_path = os.path.join(
          args.output_dir, f"checkpoint-{state.global_step}"
      )
      if state.is_world_process_zero:
          if self.user_data is not None:
              self._on_save_user_data(local_path)
  
      det_checkpoint_metadata = {
          "steps_completed": state.global_step,
          "trial_id": info.trial.trial_id,
      }
  
      def selector(x: str) -> bool:
          return x.startswith(
              (f"checkpoint-{state.global_step}/", "runs/")
          )
  
      self.core_context.checkpoint.upload(
          args.output_dir,
          metadata=det_checkpoint_metadata,
          shard=True,
          selector=selector,
      )
  
      if self.core_context.preempt.should_preempt():
          raise Exception("Process preempted / killed")
  
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 4 for calling the DetCallback obj's underlying member method code with example usage: obj.on_save(args, state, control) and returns: x