code: def test_with_random_policy(self):
      def _global_context_sampling_fn():
          abc = np.array(["a", "b", "c"])
          return {
              "global1": np.random.randint(-2, 3, [3, 4]),
              "global2": abc[np.random.randint(0, 2, [1])],
          }
  
      def _arm_context_sampling_fn():
          aabbcc = np.array(["aa", "bb", "cc"])
          return {
              "arm1": np.random.randint(-3, 4, [5]),
              "arm2": np.random.randint(-3, 4, [3, 1]),
              "arm3": aabbcc[np.random.randint(0, 2, [1])],
          }
  
      def _reward_fn(global_obs, arm_obs):
          return global_obs["global1"][2, 1] + arm_obs["arm1"][4]
  
      env = ssspe.StationaryStochasticStructuredPyEnvironment(
          _global_context_sampling_fn,
          _arm_context_sampling_fn,
          6,
          _reward_fn,
          batch_size=2,
      )
      time_step_spec = env.time_step_spec()
      action_spec = array_spec.BoundedArraySpec(
          shape=(), minimum=0, maximum=5, dtype=np.int32
      )
  
      random_policy = random_py_policy.RandomPyPolicy(
          time_step_spec=time_step_spec, action_spec=action_spec
      )
  
      for _ in range(5):
          time_step = env.reset()
          self.assertTrue(
              check_unbatched_time_step_spec(
                  time_step=time_step,
                  time_step_spec=time_step_spec,
                  batch_size=env.batch_size,
              )
          )
  
          action = random_policy.action(time_step).action
          self.assertAllEqual(action.shape, [2])
          self.assertAllGreaterEqual(action, 0)
          self.assertAllLess(action, 6)
          time_step = env.step(action)
          self.assertEqual(time_step.reward.shape, (2,))
  
file_path: agents/tf_agents/bandits/environments/stationary_stochastic_structured_py_environment_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import tensorflow
  from tf_agents.bandits.environments import stationary_stochastic_structured_py_environment
  from tf_agents.policies import random_py_policy
  from tf_agents.specs import array_spec
label_desc: Use image node_id 1 for calling the StationaryStochasticStructuredBanditPyEnvironmentTest obj's underlying member method code with example usage: obj.test_with_random_policy() and returns: dict, dict, unknown