class_docstr: A policy that outputs actions based on observation and latent context.
  
  In PEARL, policies are conditioned on current state and a latent context
  (adaptation data) variable Z. This inference network estimates the
  posterior probability of z given past transitions. It uses context
  information stored in the encoder to infer the probabilistic value of z and
  samples from a policy conditioned on z.
  
  Args:
      latent_dim (int): Latent context variable dimension.
      context_encoder (garage.torch.embeddings.ContextEncoder): Recurrent or
          permutation-invariant context encoder.
      policy (garage.torch.policies.Policy): Policy used to train the
          network.
      use_information_bottleneck (bool): True if latent context is not
          deterministic; false otherwise.
      use_next_obs (bool): True if next observation is used in context
          for distinguishing tasks; false otherwise.
class_docstr_tok: ["A","policy","that","outputs","actions","based","on","observation","and","latent","context",".","In","PEARL",",","policies","are","conditioned","on","current","state","and","a","latent","context","(","adaptation","data",")","variable","Z",".","This","inference","network","estimates","the","posterior","probability","of","z","given","past","transitions",".","It","uses","context","information","stored","in","the","encoder","to","infer","the","probabilistic","value","of","z","and","samples","from","a","policy","conditioned","on","z.","Args",":","latent_dim","(","int",")",":","Latent","context","variable","dimension",".","context_encoder","(","garage.torch.embeddings.ContextEncoder",")",":","Recurrent","or","permutation-invariant","context","encoder",".","policy","(","garage.torch.policies.Policy",")",":","Policy","used","to","train","the","network",".","use_information_bottleneck","(","bool",")",":","True","if","latent","context","is","not","deterministic",";","false","otherwise",".","use_next_obs","(","bool",")",":","True","if","next","observation","is","used","in","context","for","distinguishing","tasks",";","false","otherwise","."]
docstr: Sample action from the policy, conditioned on the task embedding.
  
  Args:
      obs (torch.Tensor): Observation values, with shape :math:`(1, O)`.
          O is the size of the flattened observation space.
  
  Returns:
      torch.Tensor: Output action value, with shape :math:`(1, A)`.
          A is the size of the flattened action space.
      dict:
          * np.ndarray[float]: Mean of the distribution.
          * np.ndarray[float]: Standard deviation of logarithmic values
              of the distribution.
docstr_tok: ["Sample","action","from","the","policy",",","conditioned","on","the","task","embedding",".","Args",":","obs","(","torch.Tensor",")",":","Observation","values",",","with","shape",":","math",":","`","(","1",",","O",")","`",".","O","is","the","size","of","the","flattened","observation","space",".","Returns",":","torch.Tensor",":","Output","action","value",",","with","shape",":","math",":","`","(","1",",","A",")","`",".","A","is","the","size","of","the","flattened","action","space",".","dict",":","*","np.ndarray","[","float","]",":","Mean","of","the","distribution",".","*","np.ndarray","[","float","]",":","Standard","deviation","of","logarithmic","values","of","the","distribution","."]
code: def get_action(self, obs):
      """Sample action from the policy, conditioned on the task embedding.
  
      Args:
          obs (torch.Tensor): Observation values, with shape :math:`(1, O)`.
              O is the size of the flattened observation space.
  
      Returns:
          torch.Tensor: Output action value, with shape :math:`(1, A)`.
              A is the size of the flattened action space.
          dict:
              * np.ndarray[float]: Mean of the distribution.
              * np.ndarray[float]: Standard deviation of logarithmic values
                  of the distribution.
  
      """
      z = self.z
      obs = torch.as_tensor(obs[None], device=global_device()).float()
      obs_in = torch.cat([obs, z], dim=1)
      action, info = self._policy.get_action(obs_in)
      return action, info
  
file_path: garage/src/garage/torch/policies/context_conditioned_policy.py
imports: import numpy
  import torch
  from torch import nn
  import torch.nn.functional
  from garage.torch import global_device, product_of_gaussians
label_desc: Use image node_id 7 for calling the ContextConditionedPolicy obj's underlying member method code with example usage: obj.get_action(obs) and returns: action,  info