docstr: Test whether Impala can be built with both frameworks.
docstr_tok: ["Test","whether","Impala","can","be","built","with","both","frameworks","."]
code: def test_impala_compilation(self):
      """Test whether Impala can be built with both frameworks."""
      config = (
          impala.ImpalaConfig()
          .environment("CartPole-v1")
          .resources(num_gpus=0)
          .rollouts(num_rollout_workers=2)
          .training(
              model={
                  "lstm_use_prev_action": True,
                  "lstm_use_prev_reward": True,
              },
          )
      )
      num_iterations = 2
  
      for _ in framework_iterator(config):
          for lstm in [False, True]:
              config.num_aggregation_workers = 0 if not lstm else 1
              config.model["use_lstm"] = lstm
              print(
                  "lstm={} aggregation-workers={}".format(
                      lstm, config.num_aggregation_workers
                  )
              )
              # Test with and w/o aggregation workers (this has nothing
              # to do with LSTMs, though).
              algo = config.build()
              for i in range(num_iterations):
                  results = algo.train()
                  print(results)
                  check_train_results(results)
  
              check_compute_single_action(
                  algo,
                  include_state=lstm,
                  include_prev_action_reward=lstm,
              )
              algo.stop()
  
file_path: ray/rllib/algorithms/impala/tests/test_impala.py
imports: import unittest
  import ray
  import ray.rllib.algorithms.impala
  from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID
  from ray.rllib.utils.framework import try_import_tf
  from ray.rllib.utils.metrics.learner_info import LEARNER_INFO, LEARNER_STATS_KEY
  from ray.rllib.utils.test_utils import check, check_compute_single_action, check_train_results, framework_iterator
label_desc: Use image node_id 3 for calling the TestIMPALA obj's underlying member method code with example usage: obj.test_impala_compilation() without return types