class_docstr: Abstract base class for torch stochastic policies.
class_docstr_tok: ["Abstract","base","class","for","torch","stochastic","policies","."]
docstr: Get a single action given an observation.
  
  Args:
      observation (np.ndarray): Observation from the environment.
          Shape is :math:`env_spec.observation_space`.
  
  Returns:
      tuple:
          * np.ndarray: Predicted action. Shape is
              :math:`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","a","single","action","given","an","observation",".","Args",":","observation","(","np.ndarray",")",":","Observation","from","the","environment",".","Shape","is",":","math",":","`","env_spec.observation_space","`",".","Returns",":","tuple",":","*","np.ndarray",":","Predicted","action",".","Shape","is",":","math",":","`","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_action(self, observation):
      r"""Get a single action given an observation.
  
      Args:
          observation (np.ndarray): Observation from the environment.
              Shape is :math:`env_spec.observation_space`.
  
      Returns:
          tuple:
              * np.ndarray: Predicted action. Shape is
                  :math:`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(observation, np.ndarray) and not isinstance(
          observation, torch.Tensor
      ):
          observation = self._env_spec.observation_space.flatten(
              observation
          )
      elif (
          isinstance(observation, np.ndarray)
          and len(observation.shape) > 1
      ):
          observation = self._env_spec.observation_space.flatten(
              observation
          )
      elif (
          isinstance(observation, torch.Tensor)
          and len(observation.shape) > 1
      ):
          observation = torch.flatten(observation)
      with torch.no_grad():
          if isinstance(observation, np.ndarray):
              observation = np_to_torch(observation)
          if not isinstance(observation, torch.Tensor):
              observation = list_to_tensor(observation)
          observation = observation.unsqueeze(0)
          action, agent_infos = self.get_actions(observation)
          return action[0], {k: v[0] for k, v in agent_infos.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 1 for calling the StochasticPolicy obj's underlying member method code with example usage: obj.get_action(observation) and returns: action,  unknown