code: def _load_trial_for_checkpoint_export(
      context_dir: pathlib.Path,
      managed_training: bool,
      trial_cls_spec: str,
      config: Dict[str, Any],
      hparams: Dict[str, Any],
  ) -> Tuple[Type[det.LegacyTrial], det.TrialContext]:
      with _local_execution_manager(context_dir):
          trial_class = load.trial_class_from_entrypoint(trial_cls_spec)
          core_context, env = _make_local_execution_env(
              managed_training=managed_training,
              test_mode=False,
              config=config,
              checkpoint_dir="/tmp",
              hparams=hparams,
          )
          trial_context = trial_class.trial_context_class(
              core_context, env
          )
      return trial_class, trial_context
  
imports: import contextlib
  import logging
  import math
  import os
  import pathlib
  import random
  import sys
  import uuid
  from typing import Any, Dict, Iterator, List, Optional, Tuple, Type
  import determined
  from determined import constants, core, gpu, load
label_desc: Use image node_id 8 for calling a global function with example usage: _load_trial_for_checkpoint_export(context_dir, managed_training, trial_cls_spec, config, hparams) and returns: trial_class,  trial_context