code: def get_trial_controller_class(
      trial_class: Type[det.LegacyTrial],
  ) -> Type[det.TrialController]:
      # Validate the Trial class
      controller_class = trial_class.trial_controller_class
      if controller_class is None:
          raise ValueError(
              f"The class attribute `trial_controller_class` of {trial_class.__name__} is "
              "None; please set it the correct subclass of `det.TrialController`",
          )
  
      if not issubclass(controller_class, det.TrialController):
          raise ValueError(
              f"The class attribute `trial_controller_class` of {trial_class.__name__} is "
              "not a valid subclass of `det.TrialController`",
          )
  
      return controller_class
  
imports: import importlib
  import logging
  import sys
  from typing import Type, cast
  import determined
label_desc: Use image node_id 2 for calling a global function with example usage: get_trial_controller_class(trial_class) and returns: controller_class