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 just before shutting down training to get off of the cluster.  This does not imply that
  the trial is complete; it may just be paused or preempted by a higher-priority task.
  
  .. warning::
      This callback runs each time a Trial shuts down gracefully to come off the cluster.
      This callback does not mean that the Trial is done training.  Additionally, if the trial
      is killed the container will be destroyed without this callback running.
docstr_tok: ["Runs","just","before","shutting","down","training","to","get","off","of","the","cluster",".","This","does","not","imply","that","the","trial","is","complete",";","it","may","just","be","paused","or","preempted","by","a","higher-priority","task",".","..","warning",":",":","This","callback","runs","each","time","a","Trial","shuts","down","gracefully","to","come","off","the","cluster",".","This","callback","does","not","mean","that","the","Trial","is","done","training",".","Additionally",",","if","the","trial","is","killed","the","container","will","be","destroyed","without","this","callback","running","."]
code: def on_trial_shutdown(self) -> None:
      """
      Runs just before shutting down training to get off of the cluster.  This does not imply that
      the trial is complete; it may just be paused or preempted by a higher-priority task.
  
      .. warning::
          This callback runs each time a Trial shuts down gracefully to come off the cluster.
          This callback does not mean that the Trial is done training.  Additionally, if the trial
          is killed the container will be destroyed without this callback running.
      """
      pass
  
file_path: determined/harness/determined/pytorch/_callback.py
imports: from typing import Any, Dict, List, Optional
label_desc: Use image node_id 2 for calling the PyTorchCallback obj's underlying member method code with example usage: obj.on_trial_shutdown() without return types