docstr: Tests, whether Model and Policy return the correct ViewRequirements.
docstr_tok: ["Tests",",","whether","Model","and","Policy","return","the","correct","ViewRequirements","."]
code: def test_traj_view_normal_case(self):
      """Tests, whether Model and Policy return the correct ViewRequirements."""
      config = (
          dqn.DQNConfig()
          .rollouts(num_envs_per_worker=10, rollout_fragment_length=4)
          .environment(
              "ray.rllib.examples.env.debug_counter_env.DebugCounterEnv"
          )
      )
  
      for _ in framework_iterator(config):
          algo = config.build()
          policy = algo.get_policy()
          view_req_model = policy.model.view_requirements
          view_req_policy = policy.view_requirements
          assert len(view_req_model) == 1, view_req_model
          assert len(view_req_policy) == 12, view_req_policy
          for key in [
              SampleBatch.OBS,
              SampleBatch.ACTIONS,
              SampleBatch.REWARDS,
              SampleBatch.TERMINATEDS,
              SampleBatch.TRUNCATEDS,
              SampleBatch.NEXT_OBS,
              SampleBatch.EPS_ID,
              SampleBatch.AGENT_INDEX,
              "weights",
          ]:
              assert key in view_req_policy
              # None of the view cols has a special underlying data_col,
              # except next-obs.
              if key != SampleBatch.NEXT_OBS:
                  assert view_req_policy[key].data_col is None
              else:
                  assert (
                      view_req_policy[key].data_col == SampleBatch.OBS
                  )
                  assert view_req_policy[key].shift == 1
          rollout_worker = algo.workers.local_worker()
          sample_batch = rollout_worker.sample()
          sample_batch = convert_ma_batch_to_sample_batch(sample_batch)
          expected_count = (
              config.num_envs_per_worker
              * config.rollout_fragment_length
          )
          assert sample_batch.count == expected_count
          for v in sample_batch.values():
              assert len(v) == expected_count
          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 3 for calling the TestTrajectoryViewAPI obj's underlying member method code with example usage: obj.test_traj_view_normal_case() without return types