class_docstr: Env that fails upon calling `step()`, but only for some remote worker indices.
  
  The worker indices that should produce the failure (a ValueError) can be
  provided by a list (of ints) under the "bad_indices" key in the env's
  config.
  
  .. testcode::
      :skipif: True
  
      from ray.rllib.env.env_context import EnvContext
      # This env will fail for workers 1 and 2 (not for the local worker
      # or any others with an index != [1|2]).
      bad_env = FaultInjectEnv(
          EnvContext(
              {"bad_indices": [1, 2]},
              worker_index=1,
              num_workers=3,
           )
      )
  
      from ray.rllib.env.env_context import EnvContext
      # This env will fail only on the first evaluation worker, not on the first
      # regular rollout worker.
      bad_env = FaultInjectEnv(
          EnvContext(
              {"bad_indices": [1], "eval_only": True},
              worker_index=2,
              num_workers=5,
          )
      )
class_docstr_tok: ["Env","that","fails","upon","calling","`","step","(",")","`",",","but","only","for","some","remote","worker","indices",".","The","worker","indices","that","should","produce","the","failure","(","a","ValueError",")","can","be","provided","by","a","list","(","of","ints",")","under","the","``","bad_indices","''","key","in","the","env's","config",".","..","testcode",":",":",":","skipif",":","True","from","ray.rllib.env.env_context","import","EnvContext","#","This","env","will","fail","for","workers","1","and","2","(","not","for","the","local","worker","#","or","any","others","with","an","index","!","=","[","1|2","]",")",".","bad_env","=","FaultInjectEnv","(","EnvContext","(","{","``","bad_indices","''",":","[","1",",","2","]","}",",","worker_index=1",",","num_workers=3",",",")",")","from","ray.rllib.env.env_context","import","EnvContext","#","This","env","will","fail","only","on","the","first","evaluation","worker",",","not","on","the","first","#","regular","rollout","worker",".","bad_env","=","FaultInjectEnv","(","EnvContext","(","{","``","bad_indices","''",":","[","1","]",",","``","eval_only","''",":","True","}",",","worker_index=2",",","num_workers=5",",",")",")"]
code: def step(self, action):
      self._increment_count()
      self._maybe_raise_error()
  
      if self.config.get("step_delay", 0) > 0.0 and (
          not self.config.get("init_delay_indices", [])
          or self.config.worker_index
          in self.config.get("step_delay_indices", [])
      ):
          # Simulate a step delay.
          time.sleep(self.config.get("step_delay"))
  
      return self.env.step(action)
  
imports: from collections import defaultdict
  import gymnasium
  import numpy
  import time
  import unittest
  import ray
  from ray.util.state import list_actors
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.algorithms.callbacks import DefaultCallbacks
  from ray.rllib.algorithms.dqn.dqn import DQNConfig
  from ray.rllib.algorithms.impala import ImpalaConfig
  from ray.rllib.algorithms.pg import PGConfig
  from ray.rllib.algorithms.pg.pg_tf_policy import PGTF2Policy
  from ray.rllib.algorithms.pg.pg_torch_policy import PGTorchPolicy
  from ray.rllib.algorithms.ppo import PPOConfig
  from ray.rllib.env.multi_agent_env import make_multi_agent
  from ray.rllib.evaluation.rollout_worker import RolloutWorker
  from ray.rllib.examples.env.random_env import RandomEnv
  from ray.rllib.utils.test_utils import framework_iterator
  from ray.tune.registry import register_env
label_desc: Use image node_id 6 for calling the FaultInjectEnv obj's underlying member method code with example usage: obj.step(action) and returns: self