code: def run_mnist(
      tmp_path: pathlib.Path, batches_trained: typing.Optional[int] = 0
  ) -> None:
      checkpoint_dir = str(tmp_path.joinpath("checkpoint"))
  
      root_logfile = tmp_path.joinpath("root_test.log")
  
      root_file_handler = logging.FileHandler(root_logfile, mode="a+")
      root_logger = logging.getLogger()  # root logger
      root_logger.setLevel(logging.INFO)
      root_logger.addHandler(root_file_handler)
  
      config = utils.load_config(
          utils.tutorials_path("mnist_pytorch/const.yaml")
      )
      hparams = config["hyperparameters"]
  
      exp_config = utils.make_default_exp_config(
          hparams,
          scheduling_unit=1,
          searcher_metric="validation_loss",
          checkpoint_dir=checkpoint_dir,
      )
      exp_config.update(config)
      exp_config["searcher"]["smaller_is_better"] = True
  
      example_path = utils.tutorials_path("mnist_pytorch/train.py")
      trial_class = utils.import_class_from_module(
          "MNistTrial", example_path
      )
      trial_class._searcher_metric = "validation_loss"
  
      if batches_trained == 0:
          return pytorch_utils.train_for_checkpoint(
              trial_class=trial_class,
              hparams=hparams,
              slots_per_trial=2,
              tmp_path=tmp_path,
              exp_config=exp_config,
              steps=1,
              trial_args={"hparams": hparams},
          )
      else:
          pytorch_utils.train_from_checkpoint(
              trial_class=trial_class,
              hparams=hparams,
              slots_per_trial=2,
              tmp_path=tmp_path,
              exp_config=exp_config,
              steps=(1, 1),
              batches_trained=batches_trained,
              trial_args={"hparams": hparams},
          )
          return True
  
file_path: determined/harness/tests/experiment/pytorch/test_examples.py
imports: import logging
  import os
  import pathlib
  import typing
  import unittest.mock
  import pytest
  import torch
  from torch.distributed import launcher
  from determined import core
  from tests.experiment import pytorch_utils, utils
  from tests.launch import test_util
label_desc: Use image node_id 3 for calling a global function with example usage: run_mnist(tmp_path, batches_trained) and returns: pytorch_utils, True