class_docstr: Abstract base class for RLlib callbacks (similar to Keras callbacks).
  
  These callbacks can be used for custom metrics and custom postprocessing.
  
  By default, all of these callbacks are no-ops. To configure custom training
  callbacks, subclass DefaultCallbacks and then set
  {"callbacks": YourCallbacksClass} in the algo config.
class_docstr_tok: ["Abstract","base","class","for","RLlib","callbacks","(","similar","to","Keras","callbacks",")",".","These","callbacks","can","be","used","for","custom","metrics","and","custom","postprocessing",".","By","default",",","all","of","these","callbacks","are","no-ops",".","To","configure","custom","training","callbacks",",","subclass","DefaultCallbacks","and","then","set","{","``","callbacks","''",":","YourCallbacksClass","}","in","the","algo","config","."]
docstr: Callback run after one or more workers have been recreated.
  
  You can access (and change) the worker(s) in question via the following code
  snippet inside your custom override of this method:
  
  Note that any "worker" inside the algorithm's `self.worker` and
  `self.evaluation_workers` WorkerSets are instances of a subclass of EnvRunner.
  
  .. testcode::
      from ray.rllib.algorithms.callbacks import DefaultCallbacks
  
      class MyCallbacks(DefaultCallbacks):
          def on_workers_recreated(
              self,
              *,
              algorithm,
              worker_set,
              worker_ids,
              is_evaluation,
              **kwargs,
          ):
              # Define what you would like to do on the recreated
              # workers:
              def func(w):
                  # Here, we just set some arbitrary property to 1.
                  if is_evaluation:
                      w._custom_property_for_evaluation = 1
                  else:
                      w._custom_property_for_training = 1
  
              # Use the `foreach_workers` method of the worker set and
              # only loop through those worker IDs that have been restarted.
              # Note that we set `local_worker=False` to NOT include it (local
              # workers are never recreated; if they fail, the entire Algorithm
              # fails).
              worker_set.foreach_worker(
                  func,
                  remote_worker_ids=worker_ids,
                  local_worker=False,
              )
  
  Args:
      algorithm: Reference to the Algorithm instance.
      worker_set: The WorkerSet object in which the workers in question reside.
          You can use a `worker_set.foreach_worker(remote_worker_ids=...,
          local_worker=False)` method call to execute custom
          code on the recreated (remote) workers. Note that the local worker is
          never recreated as a failure of this would also crash the Algorithm.
      worker_ids: The list of (remote) worker IDs that have been recreated.
      is_evaluation: Whether `worker_set` is the evaluation WorkerSet (located
          in `Algorithm.evaluation_workers`) or not.
docstr_tok: ["Callback","run","after","one","or","more","workers","have","been","recreated",".","You","can","access","(","and","change",")","the","worker","(","s",")","in","question","via","the","following","code","snippet","inside","your","custom","override","of","this","method",":","Note","that","any","``","worker","''","inside","the","algorithm","'s","`","self.worker","`","and","`","self.evaluation_workers","`","WorkerSets","are","instances","of","a","subclass","of","EnvRunner",".","..","testcode",":",":","from","ray.rllib.algorithms.callbacks","import","DefaultCallbacks","class","MyCallbacks","(","DefaultCallbacks",")",":","def","on_workers_recreated","(","self",",","*",",","algorithm",",","worker_set",",","worker_ids",",","is_evaluation",",","*","*","kwargs",",",")",":","#","Define","what","you","would","like","to","do","on","the","recreated","#","workers",":","def","func","(","w",")",":","#","Here",",","we","just","set","some","arbitrary","property","to","1.","if","is_evaluation",":","w._custom_property_for_evaluation","=","1","else",":","w._custom_property_for_training","=","1","#","Use","the","`","foreach_workers","`","method","of","the","worker","set","and","#","only","loop","through","those","worker","IDs","that","have","been","restarted",".","#","Note","that","we","set","`","local_worker=False","`","to","NOT","include","it","(","local","#","workers","are","never","recreated",";","if","they","fail",",","the","entire","Algorithm","#","fails",")",".","worker_set.foreach_worker","(","func",",","remote_worker_ids=worker_ids",",","local_worker=False",",",")","Args",":","algorithm",":","Reference","to","the","Algorithm","instance",".","worker_set",":","The","WorkerSet","object","in","which","the","workers","in","question","reside",".","You","can","use","a","`","worker_set.foreach_worker","(","remote_worker_ids=","...",",","local_worker=False",")","`","method","call","to","execute","custom","code","on","the","recreated","(","remote",")","workers",".","Note","that","the","local","worker","is","never","recreated","as","a","failure","of","this","would","also","crash","the","Algorithm",".","worker_ids",":","The","list","of","(","remote",")","worker","IDs","that","have","been","recreated",".","is_evaluation",":","Whether","`","worker_set","`","is","the","evaluation","WorkerSet","(","located","in","`","Algorithm.evaluation_workers","`",")","or","not","."]
code: def on_workers_recreated(
      self,
      *,
      algorithm: "Algorithm",
      worker_set: "WorkerSet",
      worker_ids: List[int],
      is_evaluation: bool,
      **kwargs,
  ) -> None:
      """Callback run after one or more workers have been recreated.
  
      You can access (and change) the worker(s) in question via the following code
      snippet inside your custom override of this method:
  
      Note that any "worker" inside the algorithm's `self.worker` and
      `self.evaluation_workers` WorkerSets are instances of a subclass of EnvRunner.
  
      .. testcode::
          from ray.rllib.algorithms.callbacks import DefaultCallbacks
  
          class MyCallbacks(DefaultCallbacks):
              def on_workers_recreated(
                  self,
                  *,
                  algorithm,
                  worker_set,
                  worker_ids,
                  is_evaluation,
                  **kwargs,
              ):
                  # Define what you would like to do on the recreated
                  # workers:
                  def func(w):
                      # Here, we just set some arbitrary property to 1.
                      if is_evaluation:
                          w._custom_property_for_evaluation = 1
                      else:
                          w._custom_property_for_training = 1
  
                  # Use the `foreach_workers` method of the worker set and
                  # only loop through those worker IDs that have been restarted.
                  # Note that we set `local_worker=False` to NOT include it (local
                  # workers are never recreated; if they fail, the entire Algorithm
                  # fails).
                  worker_set.foreach_worker(
                      func,
                      remote_worker_ids=worker_ids,
                      local_worker=False,
                  )
  
      Args:
          algorithm: Reference to the Algorithm instance.
          worker_set: The WorkerSet object in which the workers in question reside.
              You can use a `worker_set.foreach_worker(remote_worker_ids=...,
              local_worker=False)` method call to execute custom
              code on the recreated (remote) workers. Note that the local worker is
              never recreated as a failure of this would also crash the Algorithm.
          worker_ids: The list of (remote) worker IDs that have been recreated.
          is_evaluation: Whether `worker_set` is the evaluation WorkerSet (located
              in `Algorithm.evaluation_workers`) or not.
      """
      pass
  
imports: import gc
  import os
  import platform
  import tracemalloc
  from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Type, Union
  import gymnasium
  import numpy
  from ray.rllib.core.rl_module.rl_module import RLModule
  from ray.rllib.env.base_env import BaseEnv
  from ray.rllib.env.env_context import EnvContext
  from ray.rllib.evaluation.episode import Episode
  from ray.rllib.evaluation.episode_v2 import EpisodeV2
  from ray.rllib.evaluation.postprocessing import Postprocessing
  from ray.rllib.policy import Policy
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.utils.annotations import override, OverrideToImplementCustomLogic, PublicAPI
  from ray.rllib.utils.deprecation import deprecation_warning
  from ray.rllib.utils.exploration.random_encoder import _MovingMeanStd, compute_states_entropy, update_beta
  from ray.rllib.utils.typing import AgentID, EnvType, EpisodeType, PolicyID
  from ray.tune.callback import _CallbackMeta
  import psutil
label_desc: Use image node_id 3 for calling the DefaultCallbacks obj's underlying member method code with example usage: obj.on_workers_recreated() without return types