class_docstr: An exploration that adds Ornstein-Uhlenbeck noise to continuous actions.
  
  If explore=True, returns sampled actions plus a noise term X,
  which changes according to this formula:
  Xt+1 = -theta*Xt + sigma*N[0,stddev], where theta, sigma and stddev are
  constants. Also, some completely random period is possible at the
  beginning.
  If explore=False, returns the deterministic action.
class_docstr_tok: ["An","exploration","that","adds","Ornstein-Uhlenbeck","noise","to","continuous","actions",".","If","explore=True",",","returns","sampled","actions","plus","a","noise","term","X",",","which","changes","according","to","this","formula",":","Xt+1","=","-theta","*","Xt","+","sigma","*","N","[","0",",","stddev","]",",","where","theta",",","sigma","and","stddev","are","constants",".","Also",",","some","completely","random","period","is","possible","at","the","beginning",".","If","explore=False",",","returns","the","deterministic","action","."]
code: def _get_torch_exploration_action(
      self,
      action_dist: ActionDistribution,
      explore: bool,
      timestep: Union[int, TensorType],
  ):
      # Set last timestep or (if not given) increase by one.
      self.last_timestep = (
          timestep if timestep is not None else self.last_timestep + 1
      )
  
      # Apply exploration.
      if explore:
          # Random exploration phase.
          if self.last_timestep < self.random_timesteps:
              (
                  action,
                  _,
              ) = self.random_exploration.get_torch_exploration_action(
                  action_dist, explore=True
              )
          # Apply base-scaled and time-annealed scaled OU-noise to
          # deterministic actions.
          else:
              det_actions = action_dist.deterministic_sample()
              scale = self.scale_schedule(self.last_timestep)
              gaussian_sample = scale * torch.normal(
                  mean=torch.zeros(self.ou_state.size()), std=1.0
              ).to(self.device)
              ou_new = (
                  self.ou_theta * -self.ou_state
                  + self.ou_sigma * gaussian_sample
              )
              self.ou_state += ou_new
              high_m_low = torch.from_numpy(
                  self.action_space.high - self.action_space.low
              ).to(self.device)
              high_m_low = torch.where(
                  torch.isinf(high_m_low),
                  torch.ones_like(high_m_low).to(self.device),
                  high_m_low,
              )
              noise = (
                  scale
                  * self.ou_base_scale
                  * self.ou_state
                  * high_m_low
              )
  
              action = torch.min(
                  torch.max(
                      det_actions + noise,
                      torch.tensor(
                          self.action_space.low,
                          dtype=torch.float32,
                          device=self.device,
                      ),
                  ),
                  torch.tensor(
                      self.action_space.high,
                      dtype=torch.float32,
                      device=self.device,
                  ),
              )
  
      # No exploration -> Return deterministic actions.
      else:
          action = action_dist.deterministic_sample()
  
      # Logp=always zero.
      logp = torch.zeros(
          (action.size()[0],), dtype=torch.float32, device=self.device
      )
  
      return action, logp
  
file_path: ray/python/ray/rllib/utils/exploration/ornstein_uhlenbeck_noise.py
imports: import numpy
  from typing import Optional, Union
  from ray.rllib.models.action_dist import ActionDistribution
  from ray.rllib.utils.annotations import override, PublicAPI
  from ray.rllib.utils.exploration.gaussian_noise import GaussianNoise
  from ray.rllib.utils.framework import try_import_tf, try_import_torch, get_variable, TensorType
  from ray.rllib.utils.numpy import convert_to_numpy
  from ray.rllib.utils.schedules import Schedule
  from ray.rllib.utils.tf_utils import zero_logps_from_actions
label_desc: Use image node_id 3 for calling the OrnsteinUhlenbeckNoise obj's underlying member method code with example usage: obj._get_torch_exploration_action(action_dist, explore, timestep) and returns: action,  logp