code: def checkpoint_and_check_metrics(
      self,
      trial_class: pytorch_onevar_model.OneVarTrial,
      hparams: typing.Dict,
      tmp_path: pathlib.Path,
      steps: typing.Tuple[int, int] = (1, 1),
  ) -> typing.Tuple[
      typing.Sequence[typing.Dict[str, typing.Any]],
      typing.Sequence[typing.Dict[str, typing.Any]],
  ]:
      checkpoint_dir = str(tmp_path.joinpath("checkpoint"))
      tensorboard_path = tmp_path.joinpath("tensorboard")
      training_metrics = {"A": [], "B": []}
      validation_metrics = {"A": [], "B": []}
  
      # Trial A: train some batches and checkpoint
      (
          trial_A,
          trial_controller_A,
      ) = pytorch_utils.create_trial_and_trial_controller(
          trial_class=trial_class,
          hparams=hparams,
          trial_seed=self.trial_seed,
          max_batches=steps[0],
          min_validation_batches=steps[0],
          min_checkpoint_batches=steps[0],
          checkpoint_dir=checkpoint_dir,
          tensorboard_path=tensorboard_path,
      )
  
      trial_controller_A.run()
  
      metrics_callback = trial_A.metrics_callback
      checkpoint_callback = trial_A.checkpoint_callback
  
      training_metrics["A"] = metrics_callback.training_metrics
      assert (
          len(training_metrics["A"]) == steps[0]
      ), "training metrics did not match expected length"
      validation_metrics["A"] = metrics_callback.validation_metrics
  
      assert (
          len(checkpoint_callback.uuids) == 1
      ), "trial did not return a checkpoint UUID"
  
      # Trial A: restore from checkpoint and train
      (
          trial_A,
          trial_controller_A,
      ) = pytorch_utils.create_trial_and_trial_controller(
          trial_class=trial_class,
          hparams=hparams,
          trial_seed=self.trial_seed,
          max_batches=steps[0] + steps[1],
          min_validation_batches=steps[1],
          min_checkpoint_batches=sys.maxsize,
          checkpoint_dir=checkpoint_dir,
          tensorboard_path=tensorboard_path,
          latest_checkpoint=checkpoint_callback.uuids[0],
          steps_completed=trial_controller_A.state.batches_trained,
      )
      trial_controller_A.run()
  
      metrics_callback = trial_A.metrics_callback
      training_metrics["A"] += metrics_callback.training_metrics
      validation_metrics["A"] += metrics_callback.validation_metrics
  
      assert (
          len(training_metrics["A"]) == steps[0] + steps[1]
      ), "training metrics returned did not match expected length"
  
      # Trial B: run for some steps
      (
          trial_B,
          trial_controller_B,
      ) = pytorch_utils.create_trial_and_trial_controller(
          trial_class=trial_class,
          hparams=hparams,
          trial_seed=self.trial_seed,
          max_batches=steps[0] + steps[1],
          min_validation_batches=steps[0],
          min_checkpoint_batches=sys.maxsize,
          checkpoint_dir=checkpoint_dir,
          tensorboard_path=tensorboard_path,
      )
      trial_controller_B.run()
  
      metrics_callback = trial_B.metrics_callback
  
      training_metrics["B"] = metrics_callback.training_metrics
      validation_metrics["B"] = metrics_callback.validation_metrics
  
      for A, B in zip(training_metrics["A"], training_metrics["B"]):
          utils.assert_equivalent_metrics(A, B)
  
      for A, B in zip(validation_metrics["A"], validation_metrics["B"]):
          utils.assert_equivalent_metrics(A, B)
  
      return (training_metrics["A"], training_metrics["B"])
  
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 32 for calling the TestPyTorchTrial obj's underlying member method code with example usage: obj.checkpoint_and_check_metrics(trial_class, hparams, tmp_path, steps) and returns: training_metrics,  training_metrics