code: def __init__(
      self, trial_inst: det.LegacyTrial, *args: Any, **kwargs: Any
  ) -> None:
      super().__init__(*args, **kwargs)
  
      assert isinstance(
          trial_inst, DeepSpeedTrial
      ), "DeepSpeedTrialController needs a DeepSpeedTrial"
      self.trial = trial_inst
      self.context = cast(det_ds.DeepSpeedTrialContext, self.context)
      self._dsat_mode = self.context.get_hparams().get(
          dsat._defaults.USE_DSAT_MODE_KEY, False
      )
      if self._dsat_mode:
          searcher_name = self.context.get_experiment_config()[
              "searcher"
          ]["name"]
          assert (
              searcher_name == "custom"
          ), "`_dsat_mode` can only be set to true for Custom Searcher trials."
      self.context._set_determined_profiler(self.prof)
      if torch.cuda.is_available():
          self.prof._set_sync_device(self._sync_device)
      self.callbacks = self.trial.build_callbacks()
      for callback in self.callbacks.values():
          if util.is_overridden(
              callback.on_checkpoint_end, pytorch.PyTorchCallback
          ):
              warnings.warn(
                  "The on_checkpoint_end callback is deprecated, please use "
                  "on_checkpoint_write_end instead",
                  FutureWarning,
                  stacklevel=2,
              )
  
      if len(self.context.models) == 0:
          raise det.errors.InvalidExperimentException(
              "Must have at least one model engine. "
              "This might be caused by not wrapping your model with wrap_model_engine()"
          )
  
      self.wlsq = None  # type: Optional[layers.WorkloadSequencer]
      if self.workloads is None:
          (
              self.workloads,
              self.wlsq,
          ) = layers.make_compatibility_workloads(
              self.context._core,
              self.env,
              self.context.models[0].train_batch_size(),
          )
  
      self.steps_completed = self.env.steps_completed
  
imports: import abc
  import contextlib
  import logging
  import os
  import pathlib
  import pickle
  import random
  import time
  import warnings
  from typing import Any, Callable, Dict, Iterator, List, Optional, Type, Union, cast
  import deepspeed
  import numpy
  import torch
  from deepspeed.runtime import dataloader
  import determined
  from determined import layers, pytorch, util, workload
  from determined.pytorch import deepspeed
  from determined.pytorch import dsat
label_desc: Use image node_id 1 to create a new DeepSpeedTrialController object from inherited base classes: det with example: obj = DeepSpeedTrialController(trial_inst)