class_docstr: Abstract base class for torch stochastic policies.
class_docstr_tok: ["Abstract","base","class","for","torch","stochastic","policies","."]
docstr: Get actions given observations.
  
  Args:
      observations (np.ndarray): Observations from the environment.
          Shape is :math:`batch_dim \bullet env_spec.observation_space`.
  
  Returns:
      tuple:
          * np.ndarray: Predicted actions.
              :math:`batch_dim \bullet env_spec.action_space`.
          * dict:
              * np.ndarray[float]: Mean of the distribution.
              * np.ndarray[float]: Standard deviation of logarithmic
                  values of the distribution.
docstr_tok: ["Get","actions","given","observations",".","Args",":","observations","(","np.ndarray",")",":","Observations","from","the","environment",".","Shape","is",":","math",":","`","batch_dim","\\bullet","env_spec.observation_space","`",".","Returns",":","tuple",":","*","np.ndarray",":","Predicted","actions",".",":","math",":","`","batch_dim","\\bullet","env_spec.action_space","`",".","*","dict",":","*","np.ndarray","[","float","]",":","Mean","of","the","distribution",".","*","np.ndarray","[","float","]",":","Standard","deviation","of","logarithmic","values","of","the","distribution","."]
code: def get_actions(self, observations):
      r"""Get actions given observations.
  
      Args:
          observations (np.ndarray): Observations from the environment.
              Shape is :math:`batch_dim \bullet env_spec.observation_space`.
  
      Returns:
          tuple:
              * np.ndarray: Predicted actions.
                  :math:`batch_dim \bullet env_spec.action_space`.
              * dict:
                  * np.ndarray[float]: Mean of the distribution.
                  * np.ndarray[float]: Standard deviation of logarithmic
                      values of the distribution.
      """
      if not isinstance(observations[0], np.ndarray) and not isinstance(
          observations[0], torch.Tensor
      ):
          observations = self._env_spec.observation_space.flatten_n(
              observations
          )
  
      # frequently users like to pass lists of torch tensors or lists of
      # numpy arrays. This handles those conversions.
      if isinstance(observations, list):
          if isinstance(observations[0], np.ndarray):
              observations = np.stack(observations)
          elif isinstance(observations[0], torch.Tensor):
              observations = torch.stack(observations)
  
      if (
          isinstance(observations[0], np.ndarray)
          and len(observations[0].shape) > 1
      ):
          observations = self._env_spec.observation_space.flatten_n(
              observations
          )
      elif (
          isinstance(observations[0], torch.Tensor)
          and len(observations[0].shape) > 1
      ):
          observations = torch.flatten(observations, start_dim=1)
      with torch.no_grad():
          if isinstance(observations, np.ndarray):
              observations = np_to_torch(observations)
          if not isinstance(observations, torch.Tensor):
              observations = list_to_tensor(observations)
  
          if isinstance(self._env_spec.observation_space, akro.Image):
              observations /= 255.0  # scale image
          dist, info = self.forward(observations)
          return dist.sample().cpu().numpy(), {
              k: v.detach().cpu().numpy() for (k, v) in info.items()
          }
  
file_path: garage/src/garage/torch/policies/stochastic_policy.py
imports: import abc
  import akro
  import numpy
  import torch
  from garage.torch._functions import list_to_tensor, np_to_torch
  from garage.torch.policies.policy import Policy
label_desc: Use image node_id 2 for calling the StochasticPolicy obj's underlying member method code with example usage: obj.get_actions(observations) and returns: dist,  unknown