code: def _get_initial_and_final_steps_nested_rewards(
      observations, rewards
  ):
      batch_size = tf.nest.flatten(observations)[0].shape[0]
      if isinstance(observations, np.ndarray):
          observations = tf.constant(
              observations, dtype=tf.float32, name="observation"
          )
      zero_rewards = {
          "reward": tf.constant(
              0.0, dtype=tf.float32, shape=[batch_size]
          ),
          "constraint": tf.constant(
              0.0, dtype=tf.float32, shape=[batch_size]
          ),
      }
      initial_step = ts.TimeStep(
          tf.constant(
              ts.StepType.FIRST,
              dtype=tf.int32,
              shape=[batch_size],
              name="step_type",
          ),
          zero_rewards,
          tf.constant(
              1.0, dtype=tf.float32, shape=[batch_size], name="discount"
          ),
          observations,
      )
      rewards_nest = tf.nest.map_structure(
          lambda t: tf.convert_to_tensor(t, dtype=tf.float32), rewards
      )
      final_step = ts.TimeStep(
          tf.constant(
              ts.StepType.LAST,
              dtype=tf.int32,
              shape=[batch_size],
              name="step_type",
          ),
          rewards_nest,
          tf.constant(
              1.0, dtype=tf.float32, shape=[batch_size], name="discount"
          ),
          observations,
      )
      return initial_step, final_step
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tf_agents.bandits.agents import greedy_reward_prediction_agent
  from tf_agents.bandits.agents import neural_boltzmann_agent
  from tf_agents.bandits.agents import neural_epsilon_greedy_agent
  from tf_agents.bandits.agents import neural_falcon_agent
  from tf_agents.bandits.drivers import driver_utils
  from tf_agents.bandits.networks import global_and_arm_feature_network
  from tf_agents.bandits.policies import constraints
  from tf_agents.bandits.specs import utils
  from tf_agents.networks import network
  from tf_agents.policies import utils
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.utils import common
label_desc: Use image node_id 2 for calling a global function with example usage: _get_initial_and_final_steps_nested_rewards(observations, rewards) and returns: initial_step,  final_step