docstr: Policy gradient algorithm
  
  Args:
      model (parl.Model): model defining forward network of policy.
      lr (float): learning rate.
code: def __init__(self, model, lr):
      """Policy gradient algorithm
  
      Args:
          model (parl.Model): model defining forward network of policy.
          lr (float): learning rate.
  
      """
      # checks
      check_model_method(model, "forward", self.__class__.__name__)
      assert isinstance(lr, float)
  
      self.model = model
      device = torch.device(
          "cuda" if torch.cuda.is_available() else "cpu"
      )
      self.model.to(device)
      self.optimizer = optim.Adam(self.model.parameters(), lr=lr)
  
file_path: PARL/parl/algorithms/torch/policy_gradient.py
imports: import torch
  import torch.optim
  import parl
  from parl.utils.utils import check_model_method
  from torch.distributions import Categorical
label_desc: Use image node_id 1 to create a new PolicyGradient object from inherited base classes: parl with example: obj = PolicyGradient(model, lr)