class_docstr: Abstract base class used to define a callback that should execute during
  the lifetime of a PyTorchTrial or DeepSpeedTrial.
  
  .. warning::
      If you are defining a stateful callback (e.g., it mutates a ``self``
      attribute over its lifetime), you must also override :meth:`state_dict()` and
      :meth:`load_state_dict()` to ensure this state can be serialized and deserialized
      over checkpoints.
  
  .. warning::
      If distributed training is enabled, every GPU will execute a copy of this callback (except
      for :meth:`on_checkpoint_write_end` during PyTorchTrial training, which is only called on
      the chief). To configure a callback implementation to execute on a subset of GPUs, please
      condition your implementation on ``trial.context.distributed.get_rank()``.
class_docstr_tok: ["Abstract","base","class","used","to","define","a","callback","that","should","execute","during","the","lifetime","of","a","PyTorchTrial","or","DeepSpeedTrial",".","..","warning",":",":","If","you","are","defining","a","stateful","callback","(","e.g.",",","it","mutates","a","``","self","``","attribute","over","its","lifetime",")",",","you","must","also","override",":","meth",":","`","state_dict","(",")","`","and",":","meth",":","`","load_state_dict","(",")","`","to","ensure","this","state","can","be","serialized","and","deserialized","over","checkpoints",".","..","warning",":",":","If","distributed","training","is","enabled",",","every","GPU","will","execute","a","copy","of","this","callback","(","except","for",":","meth",":","`","on_checkpoint_write_end","`","during","PyTorchTrial","training",",","which","is","only","called","on","the","chief",")",".","To","configure","a","callback","implementation","to","execute","on","a","subset","of","GPUs",",","please","condition","your","implementation","on","``","trial.context.distributed.get_rank","(",")","``","."]
docstr: Runs before training, validation, or building dataloaders.
  
  Arguments:
      first_batch_idx (int):  The first batch index to be trained.  If the trial has already
          completed some amount of training in a previous allocation on the cluster, this will
          be nonzero.
      checkpoint_uuid (str or None):  The checkpoint from which weight, optimizer state, etc.
          will be loaded.  When ``first_batch_idx > 0`` this will contain the uuid of the
          most recent checkpoint saved by this trial.  Otherwise, it will contain the uuid of
          the checkpoint from which this trial was configured to warm start from (via
          ``source_trial_id`` or ``source_checkpoint_uuid`` in the searcher config), or None
          if no warm start was configured.
docstr_tok: ["Runs","before","training",",","validation",",","or","building","dataloaders",".","Arguments",":","first_batch_idx","(","int",")",":","The","first","batch","index","to","be","trained",".","If","the","trial","has","already","completed","some","amount","of","training","in","a","previous","allocation","on","the","cluster",",","this","will","be","nonzero",".","checkpoint_uuid","(","str","or","None",")",":","The","checkpoint","from","which","weight",",","optimizer","state",",","etc",".","will","be","loaded",".","When","``","first_batch_idx",">","0","``","this","will","contain","the","uuid","of","the","most","recent","checkpoint","saved","by","this","trial",".","Otherwise",",","it","will","contain","the","uuid","of","the","checkpoint","from","which","this","trial","was","configured","to","warm","start","from","(","via","``","source_trial_id","``","or","``","source_checkpoint_uuid","``","in","the","searcher","config",")",",","or","None","if","no","warm","start","was","configured","."]
code: def on_trial_startup(
      self, first_batch_idx: int, checkpoint_uuid: Optional[str]
  ) -> None:
      """
      Runs before training, validation, or building dataloaders.
  
      Arguments:
          first_batch_idx (int):  The first batch index to be trained.  If the trial has already
              completed some amount of training in a previous allocation on the cluster, this will
              be nonzero.
          checkpoint_uuid (str or None):  The checkpoint from which weight, optimizer state, etc.
              will be loaded.  When ``first_batch_idx > 0`` this will contain the uuid of the
              most recent checkpoint saved by this trial.  Otherwise, it will contain the uuid of
              the checkpoint from which this trial was configured to warm start from (via
              ``source_trial_id`` or ``source_checkpoint_uuid`` in the searcher config), or None
              if no warm start was configured.
      """
      pass
  
file_path: determined/harness/determined/pytorch/_callback.py
imports: from typing import Any, Dict, List, Optional
label_desc: Use image node_id 1 for calling the PyTorchCallback obj's underlying member method code with example usage: obj.on_trial_startup(first_batch_idx, checkpoint_uuid) without return types