docstr: Tests the proper auto-computation of the `rollout_fragment_length`.
docstr_tok: ["Tests","the","proper","auto-computation","of","the","`","rollout_fragment_length","`","."]
code: def test_rollout_fragment_length(self):
      """Tests the proper auto-computation of the `rollout_fragment_length`."""
      config = (
          AlgorithmConfig()
          .rollouts(
              num_rollout_workers=4,
              num_envs_per_worker=3,
              rollout_fragment_length="auto",
          )
          .training(train_batch_size=2456)
      )
      # 2456 / 3 * 4 -> 204.666 -> 204 or 205 (depending on worker index).
      # Actual train batch size: 2454 (off by only 2)
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=0) == 205
      )
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=1) == 205
      )
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=2) == 205
      )
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=3) == 204
      )
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=4) == 204
      )
  
      config = (
          AlgorithmConfig()
          .rollouts(
              num_rollout_workers=3,
              num_envs_per_worker=2,
              rollout_fragment_length="auto",
          )
          .training(train_batch_size=4000)
      )
      # 4000 / 6 -> 666.66 -> 666 or 667 (depending on worker index)
      # Actual train batch size: 4000 (perfect match)
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=0) == 667
      )
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=1) == 667
      )
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=2) == 667
      )
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=3) == 666
      )
  
      config = (
          AlgorithmConfig()
          .rollouts(
              num_rollout_workers=12,
              rollout_fragment_length="auto",
          )
          .training(train_batch_size=1342)
      )
      # 1342 / 12 -> 111.83 -> 111 or 112 (depending on worker index)
      # Actual train batch size: 1342 (perfect match)
      for i in range(11):
          self.assertTrue(
              config.get_rollout_fragment_length(worker_index=i) == 112
          )
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=11) == 111
      )
      self.assertTrue(
          config.get_rollout_fragment_length(worker_index=12) == 111
      )
  
imports: import gymnasium
  from typing import Type
  import unittest
  import ray
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.algorithms.callbacks import make_multi_callbacks
  from ray.rllib.algorithms.ppo import PPO, PPOConfig
  from ray.rllib.algorithms.ppo.tf.ppo_tf_learner import PPOTfLearner
  from ray.rllib.algorithms.ppo.torch.ppo_torch_rl_module import PPOTorchRLModule
  from ray.rllib.core.rl_module.rl_module import SingleAgentRLModuleSpec, RLModule
  from ray.rllib.core.rl_module.marl_module import MultiAgentRLModuleSpec, MultiAgentRLModule
  from ray.rllib.utils.test_utils import check
label_desc: Use image node_id 6 for calling the TestAlgorithmConfig obj's underlying member method code with example usage: obj.test_rollout_fragment_length() without return types