code: def testPolicyWithConstraints(self, policy_class):
      constraint_net = DummyNet(self._obs_spec)
      # Create an `AbsoluteConstraint` where feasible actions must have predicted
      # rewards at most 0.0.
      absolute_constraint = constraints.AbsoluteConstraint(
          self._time_step_spec,
          self._action_spec,
          constraint_network=constraint_net,
          comparator_fn=tf.less_equal,
          absolute_value=0.0,
      )
  
      tf.compat.v1.set_random_seed(1)
      policy = policy_class(
          self._time_step_spec,
          self._action_spec,
          reward_network=DummyNet(self._obs_spec),
          constraints=[absolute_constraint],
          emit_policy_info=("predicted_rewards_mean",),
      )
      observations = tf.constant([[1, 2], [2, 1]], dtype=tf.float32)
      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())
      # The expected values are obtained by passing the observation through the
      # Keras dense layer of the DummyNet (defined above).
      predicted_rewards_expected_array = np.array(
          [[4.0, 5.5, 0.0], [4.0, 5.5, -2.0]]
      )
      p_info = self.evaluate(action_step.info)
      self.assertAllClose(
          p_info.predicted_rewards_mean,
          predicted_rewards_expected_array,
      )
      # Under the `absolute_constraint`, only actions with predicted rewards
      # at most 0.0 are feasible.
      self.assertAllEqual(self.evaluate(action_step.action), [2, 2])
  
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 15 for calling the RewardPredictionPoliciesTest obj's underlying member method code with example usage: obj.testPolicyWithConstraints(policy_class) without return types