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","."]
code: def __init__(
      self,
      latent_dim,
      context_encoder,
      policy,
      use_information_bottleneck,
      use_next_obs,
  ):
      super().__init__()
      self._latent_dim = latent_dim
      self._context_encoder = context_encoder
      self._policy = policy
      self._use_information_bottleneck = use_information_bottleneck
      self._use_next_obs = use_next_obs
  
      # initialize buffers for z distribution and z
      # use buffers so latent context can be saved along with model weights
      # z_means and z_vars are the params for the gaussian distribution
      # over latent task belief maintained in the policy; z is a sample from
      # this distribution that the policy is conditioned on
      self.register_buffer("z", torch.zeros(1, latent_dim))
      self.register_buffer("z_means", torch.zeros(1, latent_dim))
      self.register_buffer("z_vars", torch.zeros(1, latent_dim))
  
      self.reset_belief()
  
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 1 to create a new ContextConditionedPolicy object from inherited base classes: nn with example: obj = ContextConditionedPolicy(latent_dim, context_encoder, policy, use_information_bottleneck, use_next_obs)