code: def test_counting_by_agent_steps(self):
      num_agents = 3
  
      config = (
          ppo.PPOConfig()
          .experimental(_enable_new_api_stack=True)
          # Env setup.
          .environment(
              MultiAgentPendulum, env_config={"num_agents": num_agents}
          )
          .rollouts(num_rollout_workers=2, rollout_fragment_length=21)
          .training(num_sgd_iter=2, train_batch_size=168)
          .framework("torch")
          .multi_agent(
              policies={f"p{i}" for i in range(num_agents)},
              policy_mapping_fn=lambda agent_id, episode, worker, **kwargs: (
                  "p{}".format(agent_id)
              ),
              count_steps_by="agent_steps",
          )
      )
  
      num_iterations = 2
      algo = config.build()
      results = None
      for i in range(num_iterations):
          results = algo.train()
      self.assertEqual(
          results["agent_timesteps_total"], results["timesteps_total"]
      )
      self.assertEqual(
          results["num_env_steps_trained"] * num_agents,
          results["num_agent_steps_trained"],
      )
      self.assertGreaterEqual(
          results["agent_timesteps_total"],
          num_iterations * config.train_batch_size,
      )
      self.assertLessEqual(
          results["agent_timesteps_total"],
          (num_iterations + 1) * config.train_batch_size,
      )
      algo.stop()
  
imports: import gymnasium
  from gymnasium.spaces import Box, Discrete
  import numpy
  import unittest
  import ray
  from ray.rllib.algorithms.callbacks import DefaultCallbacks
  import ray.rllib.algorithms.dqn
  import ray.rllib.algorithms.ppo
  from ray.rllib.examples.env.debug_counter_env import MultiAgentDebugCounterEnv
  from ray.rllib.examples.env.multi_agent import MultiAgentPendulum
  from ray.rllib.evaluation.rollout_worker import RolloutWorker
  from ray.rllib.examples.policy.episode_env_aware_policy import EpisodeEnvAwareAttentionPolicy, StatefulRandomPolicy
  from ray.rllib.models.tf.attention_net import GTrXLNet
  from ray.rllib.policy.rnn_sequencing import pad_batch_to_sequences_of_same_size
  from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID, SampleBatch, convert_ma_batch_to_sample_batch
  from ray.rllib.policy.view_requirement import ViewRequirement
  from ray.rllib.utils.annotations import override
  from ray.rllib.utils.test_utils import framework_iterator, check
label_desc: Use image node_id 9 for calling the TestTrajectoryViewAPI obj's underlying member method code with example usage: obj.test_counting_by_agent_steps() without return types