class_docstr: Tune base callback that can be extended and passed to a ``TrialRunner``
  
  Tune callbacks are called from within the ``TrialRunner`` class. There are
  several hooks that can be used, all of which are found in the submethod
  definitions of this base class.
  
  The parameters passed to the ``**info`` dict vary between hooks. The
  parameters passed are described in the docstrings of the methods.
  
  This example will print a metric each time a result is received:
  
  .. testcode::
  
      from ray import train, tune
      from ray.tune import Callback
  
  
      class MyCallback(Callback):
          def on_trial_result(self, iteration, trials, trial, result,
                              **info):
              print(f"Got result: {result['metric']}")
  
  
      def train_func(config):
          for i in range(10):
              tune.report(metric=i)
  
      tuner = tune.Tuner(
          train_func,
          run_config=train.RunConfig(
              callbacks=[MyCallback()]
          )
      )
      tuner.fit()
  
  .. testoutput::
      :hide:
  
      ...
class_docstr_tok: ["Tune","base","callback","that","can","be","extended","and","passed","to","a","``","TrialRunner","``","Tune","callbacks","are","called","from","within","the","``","TrialRunner","``","class",".","There","are","several","hooks","that","can","be","used",",","all","of","which","are","found","in","the","submethod","definitions","of","this","base","class",".","The","parameters","passed","to","the","``","*","*","info","``","dict","vary","between","hooks",".","The","parameters","passed","are","described","in","the","docstrings","of","the","methods",".","This","example","will","print","a","metric","each","time","a","result","is","received",":","..","testcode",":",":","from","ray","import","train",",","tune","from","ray.tune","import","Callback","class","MyCallback","(","Callback",")",":","def","on_trial_result","(","self",",","iteration",",","trials",",","trial",",","result",",","*","*","info",")",":","print","(","f","''","Got","result",":","{","result","[","'metric","'","]","}","''",")","def","train_func","(","config",")",":","for","i","in","range","(","10",")",":","tune.report","(","metric=i",")","tuner","=","tune.Tuner","(","train_func",",","run_config=train.RunConfig","(","callbacks=","[","MyCallback","(",")","]",")",")","tuner.fit","(",")","..","testoutput",":",":",":","hide",":","..."]
docstr: Get the state of the callback.
  
  This method should be implemented by subclasses to return a dictionary
  representation of the object's current state.
  
  This is called automatically by Tune to periodically checkpoint callback state.
  Upon :ref:`Tune experiment restoration <tune-experiment-level-fault-tolerance>`,
  callback state will be restored via :meth:`~ray.tune.Callback.set_state`.
  
  .. testcode::
  
      from typing import Dict, List, Optional
  
      from ray.tune import Callback
      from ray.tune.experiment import Trial
  
      class MyCallback(Callback):
          def __init__(self):
              self._trial_ids = set()
  
          def on_trial_start(
              self, iteration: int, trials: List["Trial"], trial: "Trial", **info
          ):
              self._trial_ids.add(trial.trial_id)
  
          def get_state(self) -> Optional[Dict]:
              return {"trial_ids": self._trial_ids.copy()}
  
          def set_state(self, state: Dict) -> Optional[Dict]:
              self._trial_ids = state["trial_ids"]
  
  Returns:
      dict: State of the callback. Should be `None` if the callback does not
      have any state to save (this is the default).
docstr_tok: ["Get","the","state","of","the","callback",".","This","method","should","be","implemented","by","subclasses","to","return","a","dictionary","representation","of","the","object","'s","current","state",".","This","is","called","automatically","by","Tune","to","periodically","checkpoint","callback","state",".","Upon",":","ref",":","`","Tune","experiment","restoration","<","tune-experiment-level-fault-tolerance",">","`",",","callback","state","will","be","restored","via",":","meth",":","`","~ray.tune.Callback.set_state","`",".","..","testcode",":",":","from","typing","import","Dict",",","List",",","Optional","from","ray.tune","import","Callback","from","ray.tune.experiment","import","Trial","class","MyCallback","(","Callback",")",":","def","__init__","(","self",")",":","self._trial_ids","=","set","(",")","def","on_trial_start","(","self",",","iteration",":","int",",","trials",":","List","[","``","Trial","''","]",",","trial",":","``","Trial","''",",","*","*","info",")",":","self._trial_ids.add","(","trial.trial_id",")","def","get_state","(","self",")","-",">","Optional","[","Dict","]",":","return","{","``","trial_ids","''",":","self._trial_ids.copy","(",")","}","def","set_state","(","self",",","state",":","Dict",")","-",">","Optional","[","Dict","]",":","self._trial_ids","=","state","[","``","trial_ids","''","]","Returns",":","dict",":","State","of","the","callback",".","Should","be","`","None","`","if","the","callback","does","not","have","any","state","to","save","(","this","is","the","default",")","."]
code: def get_state(self) -> Optional[Dict]:
      """Get the state of the callback.
  
      This method should be implemented by subclasses to return a dictionary
      representation of the object's current state.
  
      This is called automatically by Tune to periodically checkpoint callback state.
      Upon :ref:`Tune experiment restoration <tune-experiment-level-fault-tolerance>`,
      callback state will be restored via :meth:`~ray.tune.Callback.set_state`.
  
      .. testcode::
  
          from typing import Dict, List, Optional
  
          from ray.tune import Callback
          from ray.tune.experiment import Trial
  
          class MyCallback(Callback):
              def __init__(self):
                  self._trial_ids = set()
  
              def on_trial_start(
                  self, iteration: int, trials: List["Trial"], trial: "Trial", **info
              ):
                  self._trial_ids.add(trial.trial_id)
  
              def get_state(self) -> Optional[Dict]:
                  return {"trial_ids": self._trial_ids.copy()}
  
              def set_state(self, state: Dict) -> Optional[Dict]:
                  self._trial_ids = state["trial_ids"]
  
      Returns:
          dict: State of the callback. Should be `None` if the callback does not
          have any state to save (this is the default).
      """
      return None
  
imports: from abc import ABCMeta
  import glob
  import os
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
  import warnings
  from ray.util.annotations import PublicAPI, DeveloperAPI
  from ray.tune.utils.util import _atomic_save, _load_newest_checkpoint
label_desc: Use image node_id 13 for calling the Callback obj's underlying member method code with example usage: obj.get_state() and returns: None