code: def discounted_returns(
      rewards: torch.Tensor, gamma: float = 0
  ) -> torch.Tensor:
      """Perform rollout to compute reward to go
      and do a baseline subtraction."""
      if gamma == 0:
          return rewards.float()
      else:
          R = 0
          returns = []
          for r in rewards.numpy()[::-1]:
              R = r + gamma * R
              returns.insert(0, R)
          return torch.tensor(returns).float()
  
imports: import numpy
  import torch
  import torch.nn.functional
label_desc: Use image node_id 3 for calling a global function with example usage: discounted_returns(rewards, gamma) and returns: rewards, torch