class_docstr: A DDPG model implemented with PyTorch.
  
  DDPG, also known as Deep Deterministic Policy Gradient, uses actor-critic
  method to optimize the policy and Q-function prediction. It uses a
  supervised method to update the critic network and policy gradient to
  update the actor network. And there are exploration strategy, replay
  buffer and target networks involved to stabilize the training process.
  
  Args:
      env_spec (EnvSpec): Environment specification.
      policy (garage.torch.policies.Policy): Policy.
      qf (object): Q-value network.
      replay_buffer (ReplayBuffer): Replay buffer.
      sampler (garage.sampler.Sampler): Sampler.
      steps_per_epoch (int): Number of train_once calls per epoch.
      n_train_steps (int): Training steps.
      buffer_batch_size (int): Batch size of replay buffer.
      min_buffer_size (int): The minimum buffer size for replay buffer.
      exploration_policy (garage.np.exploration_policies.ExplorationPolicy): # noqa: E501
              Exploration strategy.
      target_update_tau (float): Interpolation parameter for doing the
          soft target update.
      max_episode_length_eval (int or None): Maximum length of episodes used
          for off-policy evaluation. If `None`, defaults to
          `env_spec.max_episode_length`.
      discount(float): Discount factor for the cumulative return.
      policy_weight_decay (float): L2 weight decay factor for parameters
          of the policy network.
      qf_weight_decay (float): L2 weight decay factor for parameters
          of the q value network.
      policy_optimizer (Union[type, tuple[type, dict]]): Type of optimizer
          for training policy network. This can be an optimizer type such as
          `torch.optim.Adam` or a tuple of type and dictionary, where
          dictionary contains arguments to initialize the optimizer
          e.g. `(torch.optim.Adam, {'lr' : 1e-3})`.
      qf_optimizer (Union[type, tuple[type, dict]]): Type of optimizer
          for training Q-value network. This can be an optimizer type such
          as `torch.optim.Adam` or a tuple of type and dictionary, where
          dictionary contains arguments to initialize the optimizer
          e.g. `(torch.optim.Adam, {'lr' : 1e-3})`.
      policy_lr (float): Learning rate for policy network parameters.
      qf_lr (float): Learning rate for Q-value network parameters.
      clip_pos_returns (bool): Whether or not clip positive returns.
      clip_return (float): Clip return to be in [-clip_return,
          clip_return].
      max_action (float): Maximum action magnitude.
      reward_scale (float): Reward scale.
class_docstr_tok: ["A","DDPG","model","implemented","with","PyTorch",".","DDPG",",","also","known","as","Deep","Deterministic","Policy","Gradient",",","uses","actor-critic","method","to","optimize","the","policy","and","Q-function","prediction",".","It","uses","a","supervised","method","to","update","the","critic","network","and","policy","gradient","to","update","the","actor","network",".","And","there","are","exploration","strategy",",","replay","buffer","and","target","networks","involved","to","stabilize","the","training","process",".","Args",":","env_spec","(","EnvSpec",")",":","Environment","specification",".","policy","(","garage.torch.policies.Policy",")",":","Policy",".","qf","(","object",")",":","Q-value","network",".","replay_buffer","(","ReplayBuffer",")",":","Replay","buffer",".","sampler","(","garage.sampler.Sampler",")",":","Sampler",".","steps_per_epoch","(","int",")",":","Number","of","train_once","calls","per","epoch",".","n_train_steps","(","int",")",":","Training","steps",".","buffer_batch_size","(","int",")",":","Batch","size","of","replay","buffer",".","min_buffer_size","(","int",")",":","The","minimum","buffer","size","for","replay","buffer",".","exploration_policy","(","garage.np.exploration_policies.ExplorationPolicy",")",":","#","noqa",":","E501","Exploration","strategy",".","target_update_tau","(","float",")",":","Interpolation","parameter","for","doing","the","soft","target","update",".","max_episode_length_eval","(","int","or","None",")",":","Maximum","length","of","episodes","used","for","off-policy","evaluation",".","If","`","None","`",",","defaults","to","`","env_spec.max_episode_length","`",".","discount","(","float",")",":","Discount","factor","for","the","cumulative","return",".","policy_weight_decay","(","float",")",":","L2","weight","decay","factor","for","parameters","of","the","policy","network",".","qf_weight_decay","(","float",")",":","L2","weight","decay","factor","for","parameters","of","the","q","value","network",".","policy_optimizer","(","Union","[","type",",","tuple","[","type",",","dict","]","]",")",":","Type","of","optimizer","for","training","policy","network",".","This","can","be","an","optimizer","type","such","as","`","torch.optim.Adam","`","or","a","tuple","of","type","and","dictionary",",","where","dictionary","contains","arguments","to","initialize","the","optimizer","e.g",".","`","(","torch.optim.Adam",",","{","'lr","'",":","1e-3","}",")","`",".","qf_optimizer","(","Union","[","type",",","tuple","[","type",",","dict","]","]",")",":","Type","of","optimizer","for","training","Q-value","network",".","This","can","be","an","optimizer","type","such","as","`","torch.optim.Adam","`","or","a","tuple","of","type","and","dictionary",",","where","dictionary","contains","arguments","to","initialize","the","optimizer","e.g",".","`","(","torch.optim.Adam",",","{","'lr","'",":","1e-3","}",")","`",".","policy_lr","(","float",")",":","Learning","rate","for","policy","network","parameters",".","qf_lr","(","float",")",":","Learning","rate","for","Q-value","network","parameters",".","clip_pos_returns","(","bool",")",":","Whether","or","not","clip","positive","returns",".","clip_return","(","float",")",":","Clip","return","to","be","in","[","-clip_return",",","clip_return","]",".","max_action","(","float",")",":","Maximum","action","magnitude",".","reward_scale","(","float",")",":","Reward","scale","."]
docstr: Obtain samplers and start actual training for each epoch.
  
  Args:
      trainer (Trainer): Experiment trainer.
  
  Returns:
      float: The average return in last epoch cycle.
docstr_tok: ["Obtain","samplers","and","start","actual","training","for","each","epoch",".","Args",":","trainer","(","Trainer",")",":","Experiment","trainer",".","Returns",":","float",":","The","average","return","in","last","epoch","cycle","."]
code: def train(self, trainer):
      """Obtain samplers and start actual training for each epoch.
  
      Args:
          trainer (Trainer): Experiment trainer.
  
      Returns:
          float: The average return in last epoch cycle.
  
      """
      if not self._eval_env:
          self._eval_env = trainer.get_env_copy()
      last_returns = [float("nan")]
      trainer.enable_logging = False
  
      for _ in trainer.step_epochs():
          for cycle in range(self._steps_per_epoch):
              trainer.step_episode = trainer.obtain_episodes(
                  trainer.step_itr
              )
              if hasattr(self.exploration_policy, "update"):
                  self.exploration_policy.update(trainer.step_episode)
              self.train_once(trainer.step_itr, trainer.step_episode)
              if (
                  cycle == 0
                  and self.replay_buffer.n_transitions_stored
                  >= self._min_buffer_size
              ):
                  trainer.enable_logging = True
                  eval_eps = obtain_evaluation_episodes(
                      self.policy, self._eval_env
                  )
                  last_returns = log_performance(
                      trainer.step_itr,
                      eval_eps,
                      discount=self._discount,
                  )
              trainer.step_itr += 1
  
      return np.mean(last_returns)
  
file_path: garage/src/garage/torch/algos/ddpg.py
imports: import copy
  from dowel import logger, tabular
  import numpy
  import torch
  from garage import _Default, log_performance, make_optimizer, obtain_evaluation_episodes
  from garage.np.algos import RLAlgorithm
  from garage.torch import as_torch_dict, torch_to_np
  from garage.torch._functions import zero_optim_grads
label_desc: Use image node_id 2 for calling the DDPG obj's underlying member method code with example usage: obj.train(trainer) and returns: np