class_docstr: ``pytorch.Trainer`` is an abstraction on top of a vanilla PyTorch training loop that handles
  many training details under-the-hood, and exposes APIs for configuring training-related features
  such as automatic checkpointing, validation, profiling, metrics reporting, etc.
  
  ``Trainer`` must be initialized and called from within a ``pytorch.PyTorchTrialContext``.
class_docstr_tok: ["``","pytorch.Trainer","``","is","an","abstraction","on","top","of","a","vanilla","PyTorch","training","loop","that","handles","many","training","details","under-the-hood",",","and","exposes","APIs","for","configuring","training-related","features","such","as","automatic","checkpointing",",","validation",",","profiling",",","metrics","reporting",",","etc",".","``","Trainer","``","must","be","initialized","and","called","from","within","a","``","pytorch.PyTorchTrialContext","``","."]
code: def __init__(
      self,
      trial: pytorch.PyTorchTrial,
      context: pytorch.PyTorchTrialContext,
  ):
      self._trial = trial
      self._context = context
      self._core = self._context._core
      self._distributed_backend = det._DistributedBackend()
      self._det_profiler = (
          None
      )  # type: Optional[profiler.ProfilerAgent]
      self._info = det.get_cluster_info()
      self._local_training = (
          self._info is None or self._info.task_type != "TRIAL"
      )
  
file_path: determined/harness/determined/pytorch/_trainer.py
imports: import contextlib
  import logging
  import random
  import sys
  from typing import Any, Dict, Iterator, Optional
  import numpy
  import torch
  import torch.distributed
  import determined
  from determined import core, gpu, horovod, profiler, pytorch
  from determined.horovod import hvd
label_desc: Use image node_id 1 to create a new Trainer object  with example: obj = Trainer(trial, context)