class_docstr: Simple Vanilla Policy Gradient.
  
  Args:
      env_spec (EnvSpec): Environment specification.
      policy (garage.tf.policies.StochasticPolicy): Policy.
      sampler (garage.sampler.Sampler): Sampler.
docstr: Perform one step of policy optimization given one batch of samples.
  
  Args:
      samples (list[dict]): A list of collected paths.
  
  Returns:
      numpy.float64: Average return.
docstr_tok: ["Perform","one","step","of","policy","optimization","given","one","batch","of","samples",".","Args",":","samples","(","list","[","dict","]",")",":","A","list","of","collected","paths",".","Returns",":","numpy.float64",":","Average","return","."]
code: def _train_once(self, samples):
      """Perform one step of policy optimization given one batch of samples.
  
      Args:
          samples (list[dict]): A list of collected paths.
  
      Returns:
          numpy.float64: Average return.
  
      """
      losses = []
      self._policy_opt.zero_grad()
      for path in samples:
          returns_numpy = discount_cumsum(
              path["rewards"], self._discount
          )
          returns = torch.Tensor(returns_numpy.copy())
          obs = torch.Tensor(path["observations"])
          actions = torch.Tensor(path["actions"])
          dist = self.policy(obs)[0]
          log_likelihoods = dist.log_prob(actions)
          loss = (-log_likelihoods * returns).mean()
          loss.backward()
          losses.append(loss.item())
      self._policy_opt.step()
      return np.mean(losses)
  
file_path: garage/src/garage/examples/torch/tutorial_vpg.py
imports: import numpy
  import torch
  from garage import EpisodeBatch, log_performance, wrap_experiment
  from garage.envs import PointEnv
  from garage.experiment.deterministic import set_seed
  from garage.np import discount_cumsum
  from garage.sampler import LocalSampler
  from garage.torch.policies import GaussianMLPPolicy
  from garage.trainer import Trainer
label_desc: Use image node_id 3 for calling the SimpleVPG obj's underlying member method code with example usage: obj._train_once(samples) and returns: np