class_docstr: Custom callback to verify, we can set the task on each remote sub-env.
class_docstr_tok: ["Custom","callback","to","verify",",","we","can","set","the","task","on","each","remote","sub-env","."]
docstr: Curriculum learning as seen in Ray docs
docstr_tok: ["Curriculum","learning","as","seen","in","Ray","docs"]
code: def on_train_result(
      self, *, algorithm, result: dict, **kwargs
  ) -> None:
      """Curriculum learning as seen in Ray docs"""
      if result["episode_reward_mean"] > 0.0:
          phase = 0
      else:
          phase = 1
  
      # Sub-envs are now ray.actor.ActorHandles, so we have to add
      # `remote()` here.
      algorithm.workers.foreach_env(
          lambda env: env.set_task.remote(phase)
      )
  
file_path: ray/rllib/examples/remote_base_env_with_custom_api.py
imports: import argparse
  import gymnasium
  import os
  import ray
  from ray import air, tune
  from ray.rllib.algorithms.callbacks import DefaultCallbacks
  from ray.rllib.env.apis.task_settable_env import TaskSettableEnv
  from ray.rllib.utils.test_utils import check_learning_achieved
  from ray.tune.registry import get_trainable_cls
label_desc: Use image node_id 1 for calling the TaskSettingCallback obj's underlying member method code with example usage: obj.on_train_result() without return types