code: def testPerArmRewards(self, policy_class):
      tf.compat.v1.set_random_seed(3000)
      obs_spec = bandit_spec_utils.create_per_arm_observation_spec(
          2, 3, 4
      )
      time_step_spec = ts.time_step_spec(obs_spec)
      action_spec = tensor_spec.BoundedTensorSpec((), tf.int32, 0, 3)
      reward_network = global_and_arm_feature_network.create_feed_forward_common_tower_network(
          obs_spec, (4, 3), (3, 4), (4, 2)
      )
  
      policy = policy_class(
          time_step_spec,
          action_spec,
          reward_network=reward_network,
          accepts_per_arm_features=True,
          emit_policy_info=("predicted_rewards_mean",),
      )
      action_feature = tf.cast(
          tf.reshape(tf.random.shuffle(tf.range(24)), shape=[2, 4, 3]),
          dtype=tf.float32,
      )
      observations = {
          bandit_spec_utils.GLOBAL_FEATURE_KEY: tf.constant(
              [[1, 2], [3, 4]], dtype=tf.float32
          ),
          bandit_spec_utils.PER_ARM_FEATURE_KEY: action_feature,
      }
      time_step = ts.restart(observations, batch_size=2)
      action_step = policy.action(time_step, seed=1)
      self.assertEqual(action_step.action.shape.as_list(), [2])
      self.assertEqual(action_step.action.dtype, tf.int32)
      # Initialize all variables
      self.evaluate(tf.compat.v1.global_variables_initializer())
      action, p_info, first_arm_features = self.evaluate(
          [
              action_step.action,
              action_step.info,
              observations[bandit_spec_utils.PER_ARM_FEATURE_KEY][0],
          ]
      )
      self.assertAllEqual(action.shape, [2])
      self.assertAllEqual(p_info.predicted_rewards_mean.shape, [2, 4])
      self.assertAllEqual(p_info.chosen_arm_features.shape, [2, 3])
      first_action = action[0]
      self.assertAllEqual(
          p_info.chosen_arm_features[0],
          first_arm_features[first_action],
      )
  
      # Check that zeroing out some of the actions does not affect the predicted
      # rewards for unchanged actions. This is to make sure that action feature
      # padding does not influence the behavior.
  
      if not tf.executing_eagerly():
          # The below comparison will only work in tf2 because of the random per-arm
          # observations get re-drawn in tf1.
          return
      padded_action_feature = tf.concat(
          [
              action_feature[:, 0:1, :],
              tf.zeros(shape=[2, 3, 3], dtype=tf.float32),
          ],
          axis=1,
      )
      observations = {
          bandit_spec_utils.GLOBAL_FEATURE_KEY: tf.constant(
              [[1, 2], [3, 4]], dtype=tf.float32
          ),
          bandit_spec_utils.PER_ARM_FEATURE_KEY: padded_action_feature,
      }
      time_step = ts.restart(observations, batch_size=2)
      padded_action_step = policy.action(time_step, seed=1)
      padded_p_info = self.evaluate(padded_action_step.info)
      self.assertAllEqual(
          p_info.predicted_rewards_mean[:, 0],
          padded_p_info.predicted_rewards_mean[:, 0],
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tf_agents.bandits.networks import global_and_arm_feature_network
  from tf_agents.bandits.networks import heteroscedastic_q_network
  from tf_agents.bandits.policies import boltzmann_reward_prediction_policy
  from tf_agents.bandits.policies import constraints
  from tf_agents.bandits.policies import falcon_reward_prediction_policy
  from tf_agents.bandits.policies import greedy_reward_prediction_policy
  from tf_agents.bandits.specs import utils
  from tf_agents.networks import network
  from tf_agents.specs import array_spec
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.utils import test_utils
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 11 for calling the RewardPredictionPoliciesTest obj's underlying member method code with example usage: obj.testPerArmRewards(policy_class) without return types