code: def make_trial_controller_from_trial_implementation(
      trial_class: Type[det.LegacyTrial],
      hparams: Dict,
      workloads: Optional[workload.Stream] = None,
      scheduling_unit: int = 1,
      trial_seed: int = 0,
      exp_config: Optional[Dict] = None,
      checkpoint_dir: Optional[str] = None,
      latest_checkpoint: Optional[str] = None,
      steps_completed: int = 0,
      expose_gpus: bool = False,
  ) -> det.TrialController:
      if not exp_config:
          assert hasattr(
              trial_class, "_searcher_metric"
          ), "Trial classes for unit tests should be annotated with a _searcher_metric attribute"
          searcher_metric = trial_class._searcher_metric  # type: ignore
          exp_config = make_default_exp_config(
              hparams,
              scheduling_unit,
              searcher_metric,
              checkpoint_dir=checkpoint_dir,
          )
      env = make_default_env_context(
          hparams=hparams,
          experiment_config=exp_config,
          trial_seed=trial_seed,
          latest_checkpoint=latest_checkpoint,
          steps_completed=steps_completed,
          expose_gpus=expose_gpus,
      )
  
      checkpoint_dir = checkpoint_dir or "/tmp"
      tbd_path = pathlib.Path(os.path.join("/tmp", "tensorboard"))
      core_context = core._dummy_init(
          checkpoint_storage=checkpoint_dir, tensorboard_path=tbd_path
      )
  
      distributed_backend = det._DistributedBackend()
  
      controller_class = trial_class.trial_controller_class
      assert controller_class is not None
      controller_class.pre_execute_hook(env, distributed_backend)
  
      trial_context = trial_class.trial_context_class(core_context, env)
      trial_inst = trial_class(trial_context)
  
      return controller_class.from_trial(
          trial_inst=trial_inst,
          context=trial_context,
          env=env,
          workloads=workloads,
      )
  
imports: import importlib
  import os
  import pathlib
  import re
  import unittest.mock
  from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Type
  import numpy
  import pytest
  from mypy_extensions import DefaultNamedArg
  import determined
  from determined import core, gpu, workload
  from determined.common import util
label_desc: Use image node_id 11 for calling a global function with example usage: make_trial_controller_from_trial_implementation(trial_class, hparams, workloads, scheduling_unit, trial_seed, exp_config, checkpoint_dir, latest_checkpoint, steps_completed, expose_gpus) and returns: controller_class