class_docstr: A PPO Agent.
class_docstr_tok: ["A","PPO","Agent","."]
docstr: Performs advantage calculation for the collected experience.
  
  This function is a no-op if self._compute_value_and_advantage_in_train is
  True, which means advantage calculation happens as part of agent.train().
  
  Args:
    experience: A (batch of) experience in the form of a `Trajectory`. The
      structure of `experience` must match that of `self.collect_data_spec`.
      All tensors in `experience` must be shaped `[batch, time + 1, ...]` or
      [time + 1, ...]. The "+1" is needed as the last action from the set of
      trajectories cannot be used for training, as its advantage and returns
      are unknown.
  
  Returns:
    A post processed `Trajectory` with the same shape as the input, with
      `return` and `normalized_advantage` stored inside of the policy info
      dictionary. The advantages and returns for the last transition are
      filled with 0s as they cannot be calculated.
docstr_tok: ["Performs","advantage","calculation","for","the","collected","experience",".","This","function","is","a","no-op","if","self._compute_value_and_advantage_in_train","is","True",",","which","means","advantage","calculation","happens","as","part","of","agent.train","(",")",".","Args",":","experience",":","A","(","batch","of",")","experience","in","the","form","of","a","`","Trajectory","`",".","The","structure","of","`","experience","`","must","match","that","of","`","self.collect_data_spec","`",".","All","tensors","in","`","experience","`","must","be","shaped","`","[","batch",",","time","+","1",",","...","]","`","or","[","time","+","1",",","...","]",".","The","``","+1","''","is","needed","as","the","last","action","from","the","set","of","trajectories","can","not","be","used","for","training",",","as","its","advantage","and","returns","are","unknown",".","Returns",":","A","post","processed","`","Trajectory","`","with","the","same","shape","as","the","input",",","with","`","return","`","and","`","normalized_advantage","`","stored","inside","of","the","policy","info","dictionary",".","The","advantages","and","returns","for","the","last","transition","are","filled","with","0s","as","they","can","not","be","calculated","."]
code: def _preprocess_sequence(self, experience):
      """Performs advantage calculation for the collected experience.
  
      This function is a no-op if self._compute_value_and_advantage_in_train is
      True, which means advantage calculation happens as part of agent.train().
  
      Args:
        experience: A (batch of) experience in the form of a `Trajectory`. The
          structure of `experience` must match that of `self.collect_data_spec`.
          All tensors in `experience` must be shaped `[batch, time + 1, ...]` or
          [time + 1, ...]. The "+1" is needed as the last action from the set of
          trajectories cannot be used for training, as its advantage and returns
          are unknown.
  
      Returns:
        A post processed `Trajectory` with the same shape as the input, with
          `return` and `normalized_advantage` stored inside of the policy info
          dictionary. The advantages and returns for the last transition are
          filled with 0s as they cannot be calculated.
      """
      if self._compute_value_and_advantage_in_train:
          return experience
  
      return self._preprocess(experience)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from typing import Optional, Text, Tuple
  from absl import logging
  import gin
  from six.moves import range
  from six.moves import zip
  import tensorflow
  from tf_agents.agents import data_converter
  from tf_agents.agents import tf_agent
  from tf_agents.agents.ppo import ppo_policy
  from tf_agents.agents.ppo import ppo_utils
  from tf_agents.networks import network
  from tf_agents.policies import greedy_policy
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import eager_utils
  from tf_agents.utils import nest_utils
  from tf_agents.utils import object_identity
  from tf_agents.utils import tensor_normalizer
  from tf_agents.utils import value_ops
label_desc: Use image node_id 8 for calling the PPOAgent obj's underlying member method code with example usage: obj._preprocess_sequence(experience) and returns: self, experience