class_docstr: A randomly acting environment that publishes an action-mask each step.
code: def __init__(self, config):
      super().__init__(config)
      self._skip_env_checking = True
      # Masking only works for Discrete actions.
      assert isinstance(self.action_space, Discrete)
      # Add action_mask to observations.
      self.observation_space = Dict(
          {
              "action_mask": Box(
                  0.0, 1.0, shape=(self.action_space.n,)
              ),
              "observations": self.observation_space,
          }
      )
      self.valid_actions = None
  
file_path: ray/python/ray/rllib/examples/env/action_mask_env.py
imports: from gymnasium.spaces import Box, Dict, Discrete
  import numpy
  from ray.rllib.examples.env.random_env import RandomEnv
label_desc: Use image node_id 1 to create a new ActionMaskEnv object from inherited base classes: RandomEnv with example: obj = ActionMaskEnv(config)