code: def reproducibility_test(
      controller_fn: Callable[[workload.Stream], det.TrialController],
      steps: int,
      validation_freq: int,
      seed: int = 123,
      scheduling_unit: int = 1,
  ) -> Tuple[
      Tuple[Sequence[Dict[str, Any]], Sequence[Dict[str, Any]]],
      Tuple[Sequence[Dict[str, Any]], Sequence[Dict[str, Any]]],
  ]:
      training_metrics = {}
      validation_metrics = {}
  
      def make_workloads(tag: str) -> workload.Stream:
          nonlocal training_metrics
          nonlocal validation_metrics
  
          trainer = TrainAndValidate()
  
          yield from trainer.send(
              steps, validation_freq, scheduling_unit=scheduling_unit
          )
          tm, vm = trainer.result()
  
          training_metrics[tag] = tm
          validation_metrics[tag] = vm
  
      # Trial A
      os.environ["DET_TRIAL_SEED"] = str(seed)
      controller_A = controller_fn(make_workloads("A"))
      controller_A.run()
  
      # Trial B
      assert os.environ["DET_TRIAL_SEED"] == str(seed)
      controller_B = controller_fn(make_workloads("B"))
      controller_B.run()
  
      assert len(training_metrics["A"]) == len(training_metrics["B"])
      for A, B in zip(training_metrics["A"], training_metrics["B"]):
          assert_equivalent_metrics(A, B)
  
      assert len(validation_metrics["A"]) == len(
          validation_metrics["B"]
      )
      for A, B in zip(validation_metrics["A"], validation_metrics["B"]):
          assert_equivalent_metrics(A, B)
  
      return (
          (training_metrics["A"], validation_metrics["A"]),
          (training_metrics["B"], validation_metrics["B"]),
      )
  
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 12 for calling a global function with example usage: reproducibility_test(controller_fn, steps, validation_freq, seed, scheduling_unit) and returns: training_metrics,  validation_metrics,  training_metrics,  validation_metrics