code: def testSampleBatch(self):
      action_spec = {
          "continuous1": tensor_spec.BoundedTensorSpec(
              [_ACTION_SIZE_CONTINUOUS], tf.float32, 0.0, 1.0
          ),
          "continuous2": tensor_spec.BoundedTensorSpec(
              [_ACTION_SIZE_CONTINUOUS], tf.float32, 0.0, 1.0
          ),
          "discrete": tensor_spec.BoundedTensorSpec(
              [_ACTION_SIZE_DISCRETE], tf.int32, 0, 1
          ),
      }
      sampler = qtopt_cem_actions_sampler_continuous_and_one_hot.GaussianActionsSampler(
          action_spec=action_spec,
          sample_clippers=[[], [], []],
          sub_actions_fields=[
              ["continuous1"],
              ["discrete"],
              ["continuous2"],
          ],
          sample_rejecters=[None, None, dummy_sample_rejecter],
      )
  
      mean = tf.constant(_MEAN)
      var = tf.constant(_VAR)
      mean = {
          "continuous1": tf.broadcast_to(
              mean, [_BATCH, _ACTION_SIZE_CONTINUOUS]
          ),
          "continuous2": tf.broadcast_to(
              mean, [_BATCH, _ACTION_SIZE_CONTINUOUS]
          ),
          "discrete": tf.zeros([_BATCH, _ACTION_SIZE_DISCRETE]),
      }
      var = {
          "continuous1": tf.broadcast_to(
              var, [_BATCH, _ACTION_SIZE_CONTINUOUS]
          ),
          "continuous2": tf.broadcast_to(
              var, [_BATCH, _ACTION_SIZE_CONTINUOUS]
          ),
          "discrete": tf.zeros([_BATCH, _ACTION_SIZE_DISCRETE]),
      }
  
      actions = sampler.sample_batch_and_clip(_NUM_SAMPLES, mean, var)
  
      self.assertEqual(
          (_BATCH, _NUM_SAMPLES, _ACTION_SIZE_CONTINUOUS),
          actions["continuous1"].shape,
      )
      self.assertEqual(
          (_BATCH, _NUM_SAMPLES, _ACTION_SIZE_CONTINUOUS),
          actions["continuous2"].shape,
      )
      self.assertEqual(
          (_BATCH, _NUM_SAMPLES, _ACTION_SIZE_DISCRETE),
          actions["discrete"].shape,
      )
  
      actions_ = self.evaluate(actions)
      flat_actions = tf.nest.flatten(actions_)
      flat_action_spec = tf.nest.flatten(action_spec)
      for i in range(len(flat_action_spec)):
          self.assertTrue(
              (flat_actions[i] <= flat_action_spec[i].maximum).all()
          )
          self.assertTrue(
              (flat_actions[i] >= flat_action_spec[i].minimum).all()
          )
  
      # make sure discrete part
      # make sure 0 for continuous part
      expected_actions_discrete = tf.broadcast_to(
          tf.constant(
              [
                  [1.0, 0.0, 0.0],
                  [1.0, 0.0, 0.0],
                  [0.0, 1.0, 0.0],
                  [0.0, 0.0, 1.0],
                  [0.0, 0.0, 1.0],
              ]
          ),
          tf.constant([_BATCH, _NUM_SAMPLES, _ACTION_SIZE_DISCRETE]),
      )
  
      self.assertAllClose(
          expected_actions_discrete, actions_["discrete"]
      )
  
      expected_actions_continuous1 = tf.zeros(
          [_BATCH, 2, _ACTION_SIZE_CONTINUOUS]
      )
      self.assertAllClose(
          expected_actions_continuous1,
          actions_["continuous1"][:, 3:, :],
      )
  
      self.assertAllGreaterEqual(
          actions_["continuous1"][:, 0:3, :], 0.0
      )
      self.assertAllLessEqual(actions_["continuous1"][:, 0:3, :], 1.0)
  
      expected_actions_continuous2 = tf.zeros(
          [_BATCH, 2, _ACTION_SIZE_CONTINUOUS]
      )
      self.assertAllClose(
          expected_actions_continuous2,
          actions_["continuous2"][:, 1:3, :],
      )
      self.assertAllGreaterEqual(actions_["continuous2"][:, 2:, :], 0.0)
      self.assertAllLessEqual(actions_["continuous2"][:, 2:, :], 1.0)
  
file_path: agents/tf_agents/policies/samplers/qtopt_cem_actions_sampler_continuous_and_one_hot_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import tensorflow
  from tf_agents.policies.samplers import qtopt_cem_actions_sampler_continuous_and_one_hot
  from tf_agents.specs import tensor_spec
label_desc: Use image node_id 1 for calling the ActionsSamplerTest obj's underlying member method code with example usage: obj.testSampleBatch() without return types