code: def get_optimistic_exploration_action(self, obs):
      act_mean, act_log_std = self.model.policy(obs)
      act_std = paddle.exp(act_log_std)
      normal = Normal(act_mean, act_std)
      pre_tanh_mu_T = normal.sample([1])
  
      tanh_mu_T = paddle.tanh(pre_tanh_mu_T)
  
      # Get the upper bound of the Q estimate
      Q1, Q2 = self.model.value(obs, tanh_mu_T[0])
      mu_Q = (Q1 + Q2) / 2.0
      sigma_Q = paddle.abs(Q1 - Q2) / 2.0
  
      Q_UB = mu_Q + self.beta * sigma_Q
  
      # Obtain the gradient of Q_UB wrt to a with a evaluated at mu_t
      grad = paddle.grad(Q_UB, pre_tanh_mu_T)
      grad = grad[0]
      assert grad is not None
      assert pre_tanh_mu_T.shape == grad.shape
  
      # Obtain Sigma_T (the covariance of the normal distribution)
      Sigma_T = paddle.pow(act_std, 2)
  
      # The dividor is (g^T Sigma g) ** 0.5
      # Sigma is diagonal, so this works out to be
      # ( sum_{i=1}^k (g^(i))^2 (sigma^(i))^2 ) ** 0.5
      denom = (
          paddle.sqrt(
              paddle.sum(paddle.multiply(paddle.pow(grad, 2), Sigma_T))
          )
          + 10e-6
      )
  
      # Obtain the change in mu
      mu_C = (
          math.sqrt(2.0 * self.delta)
          * paddle.multiply(Sigma_T, grad)
          / denom
      )
      assert mu_C.shape == pre_tanh_mu_T.shape
  
      mu_E = pre_tanh_mu_T + mu_C
      mu_E = paddle.squeeze(mu_E, axis=0)
      # Construct the tanh normal distribution and sample the exploratory action from it
      assert mu_E.shape == act_std.shape
  
      dist = Normal(mu_E, act_std)
      z = dist.sample([1]).detach()
      action = paddle.tanh(z)
      return action[0]
  
file_path: PARL/parl/algorithms/paddle/oac.py
imports: import parl
  import paddle
  from paddle.distribution import Normal
  import paddle.nn.functional
  from parl.utils.utils import check_model_method
  from copy import deepcopy
  import math
label_desc: Use image node_id 4 for calling the OAC obj's underlying member method code with example usage: obj.get_optimistic_exploration_action(obs) and returns: action