class_docstr: Continuous Gaussian actions sampler.
  
  Supports in nested action_spec with 1d continuous actions or 1d
  discrete actions.
  
  Given a batch of distribution params(including mean and var), sample and
  return [B, N, A] actions, where 'B' means batch_size, 'N' means num_samples,
  'A' means action_size.
class_docstr_tok: ["Continuous","Gaussian","actions","sampler",".","Supports","in","nested","action_spec","with","1d","continuous","actions","or","1d","discrete","actions",".","Given","a","batch","of","distribution","params","(","including","mean","and","var",")",",","sample","and","return","[","B",",","N",",","A","]","actions",",","where","'","B","'","means","batch_size",",","'N","'","means","num_samples",",","'","A","'","means","action_size","."]
docstr: Samples and clips a batch of actions [B, N, A] with mean and var.
  
  Args:
    num_samples: Number of actions to sample each round.
    mean: A nested structure containing [B, A] shaped tensor representing the
      mean of the actions to be sampled.
    var: A nested structure containing [B, A] shaped tensor representing the
      variance of the actions to be sampled.
    state: Nested state tensor constructed according to oberservation_spec of
      the task.
  
  Returns:
    actions:  A nested structure containing tensor of sampled actions with
      shape [B, N, A]
docstr_tok: ["Samples","and","clips","a","batch","of","actions","[","B",",","N",",","A","]","with","mean","and","var",".","Args",":","num_samples",":","Number","of","actions","to","sample","each","round",".","mean",":","A","nested","structure","containing","[","B",",","A","]","shaped","tensor","representing","the","mean","of","the","actions","to","be","sampled",".","var",":","A","nested","structure","containing","[","B",",","A","]","shaped","tensor","representing","the","variance","of","the","actions","to","be","sampled",".","state",":","Nested","state","tensor","constructed","according","to","oberservation_spec","of","the","task",".","Returns",":","actions",":","A","nested","structure","containing","tensor","of","sampled","actions","with","shape","[","B",",","N",",","A","]"]
code: def sample_batch_and_clip(self, num_samples, mean, var, state=None):
      """Samples and clips a batch of actions [B, N, A] with mean and var.
  
      Args:
        num_samples: Number of actions to sample each round.
        mean: A nested structure containing [B, A] shaped tensor representing the
          mean of the actions to be sampled.
        var: A nested structure containing [B, A] shaped tensor representing the
          variance of the actions to be sampled.
        state: Nested state tensor constructed according to oberservation_spec of
          the task.
  
      Returns:
        actions:  A nested structure containing tensor of sampled actions with
          shape [B, N, A]
      """
  
      def sample_and_transpose(mean, var, spec):
          dist = tfp.distributions.Normal(loc=mean, scale=tf.sqrt(var))
          sample = tf.transpose(dist.sample(num_samples), [1, 0, 2])
          return tf.cast(sample, spec.dtype)
  
      # [B, N, A]
      samples = tf.nest.map_structure(
          sample_and_transpose, mean, var, self._action_spec
      )
  
      actions = tf.nest.map_structure(
          common.clip_to_spec, samples, self._action_spec
      )
      if self._sample_clippers:
          for sample_clipper in self._sample_clippers:
              actions = sample_clipper(actions, state)
  
      return actions
  
file_path: agents/tf_agents/policies/samplers/qtopt_cem_actions_sampler_hybrid.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gin
  import tensorflow
  import tensorflow_probability
  from tf_agents.policies.samplers import qtopt_cem_actions_sampler
  from tf_agents.utils import common
label_desc: Use image node_id 3 for calling the GaussianActionsSampler obj's underlying member method code with example usage: obj.sample_batch_and_clip(num_samples, mean, var, state) and returns: actions, tf