docstr: Scores the sample actions using map_fn as part of CEM while loop.
  
  Args:
    observation: A batch of observation tensors or NamedTuples, whatever the
      q_func will handle. CEM is agnostic to it.
    sample_actions: A [N, B, A] sized tensor, where batch is the batch size, N
      is the sample size for the CEM, a is the size of the action space.
    q_network: the q_network to use for calculating scores.
  
  Returns:
    a tensor of shape [B, N] representing the scores for the actions
docstr_tok: ["Scores","the","sample","actions","using","map_fn","as","part","of","CEM","while","loop",".","Args",":","observation",":","A","batch","of","observation","tensors","or","NamedTuples",",","whatever","the","q_func","will","handle",".","CEM","is","agnostic","to","it",".","sample_actions",":","A","[","N",",","B",",","A","]","sized","tensor",",","where","batch","is","the","batch","size",",","N","is","the","sample","size","for","the","CEM",",","a","is","the","size","of","the","action","space",".","q_network",":","the","q_network","to","use","for","calculating","scores",".","Returns",":","a","tensor","of","shape","[","B",",","N","]","representing","the","scores","for","the","actions"]
code: def _score_with_map_fn(self, observation, sample_actions, q_network):
      """Scores the sample actions using map_fn as part of CEM while loop.
  
      Args:
        observation: A batch of observation tensors or NamedTuples, whatever the
          q_func will handle. CEM is agnostic to it.
        sample_actions: A [N, B, A] sized tensor, where batch is the batch size, N
          is the sample size for the CEM, a is the size of the action space.
        q_network: the q_network to use for calculating scores.
  
      Returns:
        a tensor of shape [B, N] representing the scores for the actions
      """
  
      # Get the score of a single sample_action: [B, A]
      def single_sample_score_fn(sample_action):
          """Gets the score of a single sample action for the observation."""
          q_values, _ = q_network((observation, sample_action))  # [B]
  
          return q_values
  
      # Main _score function.
      # 1. Observation (including the image) should be reused for each of the
      #    actions.
      # 2. Call the q_func with the action, observation combo.
      # sample_actions  # [N, B, A]
      scores_t = tf.map_fn(
          single_sample_score_fn, sample_actions, dtype=tf.float32
      )  # [N, B]
      # Note that we only want to squeeze the last dimension in case the batch=1.
      # Else, while loop will throw an error since the samples enter the loop as
      # (1, N, 1) and will exit (N,).
      return tf.transpose(scores_t, [1, 0])
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl import flags
  from absl import logging
  from absl.testing import parameterized
  import numpy
  import tensorflow
  import tensorflow_probability
  from tf_agents.networks import network
  from tf_agents.policies import qtopt_cem_policy
  from tf_agents.policies.samplers import qtopt_cem_actions_sampler_continuous
  from tf_agents.policies.samplers import qtopt_cem_actions_sampler_continuous_and_one_hot
  from tf_agents.policies.samplers import qtopt_cem_actions_sampler_hybrid
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
label_desc: Use image node_id 7 for calling the CEMPolicyTest obj's underlying member method code with example usage: obj._score_with_map_fn(observation, sample_actions, q_network) and returns: tf, q_values