code: def test_custom_rnn_state_values(self):
      h = {"some": {"here": np.array([1.0, 2.0, 3.0])}}
  
      class StatefulPolicy(RandomPolicy):
          def compute_actions(
              self,
              obs_batch,
              state_batches=None,
              prev_action_batch=None,
              prev_reward_batch=None,
              episodes=None,
              explore=True,
              timestep=None,
              **kwargs,
          ):
              obs_shape = (len(obs_batch),)
              actions = np.zeros(obs_shape, dtype=np.int32)
              states = tree.map_structure(
                  lambda x: np.ones(obs_shape + x.shape) * x, h
              )
  
              return actions, [states], {}
  
          def get_initial_state(self):
              return [{}]  # empty dict
  
          def is_recurrent(self):
              # TODO: avnishn automatically infer this.
              return True
  
      ev = RolloutWorker(
          env_creator=lambda _: gym.make("CartPole-v1"),
          default_policy_class=StatefulPolicy,
          config=(
              AlgorithmConfig().rollouts(
                  rollout_fragment_length=5,
                  num_rollout_workers=0,
              )
              # Force `state_in_0` to be repeated every ts in the collected batch
              # (even though we don't even have a model that would care about this).
              .training(model={"max_seq_len": 1})
          ),
      )
      batch = ev.sample()
      batch = convert_ma_batch_to_sample_batch(batch)
      self.assertEqual(batch.count, 5)
      check(batch["state_in_0"][0], {})
      check(batch["state_out_0"][0], h)
      for i in range(1, 5):
          check(batch["state_in_0"][i], h)
          check(batch["state_out_0"][i], h)
  
imports: import gymnasium
  import numpy
  import random
  import tree
  import unittest
  import ray
  from ray.tune.registry import register_env
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.algorithms.dqn.dqn import DQNConfig
  from ray.rllib.algorithms.dqn.dqn_tf_policy import DQNTFPolicy
  from ray.rllib.algorithms.ppo import PPOConfig
  from ray.rllib.env.multi_agent_env import make_multi_agent, MultiAgentEnvWrapper
  from ray.rllib.evaluation.episode import Episode
  from ray.rllib.evaluation.rollout_worker import get_global_worker, RolloutWorker
  from ray.rllib.evaluation.tests.test_rollout_worker import MockPolicy
  from ray.rllib.examples.policy.random_policy import RandomPolicy
  from ray.rllib.examples.env.multi_agent import MultiAgentCartPole, BasicMultiAgent, EarlyDoneMultiAgent, FlexAgentsMultiAgent, RoundRobinMultiAgent, SometimesZeroAgentsMultiAgent
  from ray.rllib.policy.policy import PolicySpec
  from ray.rllib.policy.sample_batch import convert_ma_batch_to_sample_batch
  from ray.rllib.tests.test_nested_observation_spaces import NestedMultiAgentEnv
  from ray.rllib.utils.numpy import one_hot
  from ray.rllib.utils.test_utils import check
label_desc: Use image node_id 15 for calling the TestMultiAgentEnv obj's underlying member method code with example usage: obj.test_custom_rnn_state_values() and returns: actions,  list,  dict, list, True