code: def run(local: bool = False):
      """Initializes the trial and runs the training loop.
  
      This method configures the appropriate training parameters for both local and on-cluster
      training modes. It is an example of a standalone training script that can run both locally and
      on-cluster without any code changes.
  
      To run the training code solely locally or on-cluster, remove the conditional parameter logic
      for the unneeded training mode.
  
      Arguments:
          local: Whether to run this script locally. Defaults to false (on-cluster training).
      """
  
      info = det.get_cluster_info()
  
      if local:
          # For convenience, use hparams from const.yaml for local mode.
          conf = yaml.safe_load(
              pathlib.Path("./const.yaml").read_text()
          )
          hparams = conf["hyperparameters"]
          max_length = pytorch.Batch(100)  # Train for 100 batches.
          latest_checkpoint = None
      else:
          hparams = (
              info.trial.hparams
          )  # Get instance of hparam values from Determined cluster info.
          max_length = None  # On-cluster training trains for the searcher's configured length.
          latest_checkpoint = (
              info.latest_checkpoint
          )  # (Optional) Configure checkpoint for pause/resume functionality.
  
      with pytorch.init() as train_context:
          trial = MNistTrial(train_context, hparams=hparams)
          trainer = pytorch.Trainer(trial, train_context)
          trainer.fit(
              max_length=max_length, latest_checkpoint=latest_checkpoint
          )
  
file_path: determined/harness/tests/experiment/fixtures/pytorch_amp/train.py
imports: import logging
  import pathlib
  from typing import Any, Dict
  import data
  import model
  import torch
  from ruamel import yaml
  from torch import nn
  import determined
  from determined import pytorch
label_desc: Use image node_id 1 for calling a global function with example usage: run(local) without return types