code: def get_general_advantage_estimation_values(self, rewards, values):
      # values contain n+1 elements (t ... t+n+1), rewards contain n elements (t ... t + n)
      bootstrap_extended_rewards = np.array(
          rewards.tolist() + [values[-1]]
      )
  
      # Approximation based calculation of GAE (mathematically correct only when Tmax = inf,
      # although in practice works even in much smaller Tmax values, e.g. 20)
      deltas = (
          rewards
          + self.ap.algorithm.discount * values[1:]
          - values[:-1]
      )
      gae = self.discount(
          deltas,
          self.ap.algorithm.discount * self.ap.algorithm.gae_lambda,
      )
  
      if self.ap.algorithm.estimate_state_value_using_gae:
          discounted_returns = np.expand_dims(gae + values[:-1], -1)
      else:
          discounted_returns = np.expand_dims(
              np.array(
                  self.discount(
                      bootstrap_extended_rewards,
                      self.ap.algorithm.discount,
                  )
              ),
              1,
          )[:-1]
      return gae, discounted_returns
  
imports: from typing import Union
  import numpy
  import scipy.signal
  from rl_coach.agents.policy_optimization_agent import PolicyOptimizationAgent, PolicyGradientRescaler
  from rl_coach.architectures.embedder_parameters import InputEmbedderParameters
  from rl_coach.architectures.head_parameters import PolicyHeadParameters, VHeadParameters
  from rl_coach.architectures.middleware_parameters import FCMiddlewareParameters
  from rl_coach.base_parameters import AlgorithmParameters, NetworkParameters, AgentParameters
  from rl_coach.exploration_policies.categorical import CategoricalParameters
  from rl_coach.exploration_policies.continuous_entropy import ContinuousEntropyParameters
  from rl_coach.logger import screen
  from rl_coach.memories.episodic.single_episode_buffer import SingleEpisodeBufferParameters
  from rl_coach.spaces import DiscreteActionSpace, BoxActionSpace
  from rl_coach.utils import last_sample
label_desc: Use image node_id 4 for calling the ActorCriticAgent obj's underlying member method code with example usage: obj.get_general_advantage_estimation_values(rewards, values) and returns: gae,  discounted_returns