code: def discounted_returns(
      discount, max_len, rewards, name="discounted_returns"
  ):
      """Calculate discounted returns.
  
      Args:
          discount (float): Discount factor.
          max_len (int): Maximum length of a single episode.
          rewards (tf.Tensor): A 2D vector of per-step rewards with shape
              :math:`(N, T)`, where :math:`N` is the batch dimension (number of
              episodes) and :math:`T` is the maximum episode length experienced
              by the agent.
          name (string): Name of the operation. None by default.
  
      Returns:
          tf.Tensor: Tensor of discounted returns.
      """
      with tf.name_scope(name):
          gamma = tf.constant(
              float(discount), dtype=tf.float32, shape=[max_len, 1, 1]
          )
          return_filter = tf.math.cumprod(gamma, axis=0, exclusive=True)
          rewards_pad = tf.expand_dims(
              tf.concat([rewards, tf.zeros_like(rewards[:, :-1])], 1),
              axis=2,
          )
          returns = tf.nn.conv1d(
              rewards_pad, return_filter, stride=1, padding="VALID"
          )
  
      return returns
  
imports: import collections
  import numpy
  import tensorflow
label_desc: Use image node_id 22 for calling a global function with example usage: discounted_returns(discount, max_len, rewards, name) and returns: returns