code: def test_trial_checkpoint_loading(
      ckpt: str,
      istrial: bool,
      trial_spec: typing.Optional[str],
      trial_kwargs: typing.Dict[str, typing.Any],
  ):
      checkpoint_dir = os.path.join(
          utils.fixtures_path("ancient-checkpoints"), f"{ckpt}"
      )
      trial_class = None
      if trial_spec:
          with det.import_from_path(
              os.path.join(checkpoint_dir, "code")
          ):
              file, cls = trial_spec.split(":")
              module = importlib.import_module(file)
              trial_class = getattr(module, cls)
      trial = pytorch.load_trial_from_checkpoint_path(
          checkpoint_dir,
          trial_class=trial_class,
          trial_kwargs=trial_kwargs,
          torch_load_kwargs={"map_location": "cpu"},
      )
      if istrial:
          assert isinstance(trial, pytorch.PyTorchTrial), type(trial)
      else:
          assert isinstance(trial, torch.nn.Module), type(trial)
  
imports: import contextlib
  import importlib
  import io
  import os
  import pathlib
  import sys
  import typing
  from unittest import mock
  import numpy
  import pytest
  import torch
  from _pytest import monkeypatch
  from torch.distributed import launcher
  import determined
  from determined import pytorch
  from tests.experiment import pytorch_utils, utils
  from tests.experiment.fixtures import pytorch_onevar_model
label_desc: Use image node_id 2 for calling a global function with example usage: test_trial_checkpoint_loading(ckpt, istrial, trial_spec, trial_kwargs) without return types