class_docstr: Tests reward related functions.
      
docstr: Tests :func:`texar.tf.losses.rewards._discount_reward_py_1d`
          
code: def test_discount_reward_py_1d(self):
      """Tests :func:`texar.tf.losses.rewards._discount_reward_py_1d`"""
      reward = np.ones([2], dtype=np.float64)
      sequence_length = [3, 5]
  
      discounted_reward_1 = _discount_reward_py_1d(
          reward, sequence_length, discount=1.0
      )
  
      discounted_reward_2 = _discount_reward_py_1d(
          reward, sequence_length, discount=0.1
      )
  
      r = discounted_reward_1
      for i in range(5):
          if i < 3:
              self.assertEqual(r[0, i], 1)
          else:
              self.assertEqual(r[0, i], 0)
          self.assertEqual(r[1, i], 1)
  
      r = discounted_reward_2
      for i in range(5):
          if i < 3:
              self.assertAlmostEqual(r[0, i], 0.1 ** (2 - i))
          else:
              self.assertAlmostEqual(r[0, i], 0)
          self.assertAlmostEqual(r[1, i], 0.1 ** (4 - i))
  
file_path: texar/tests/losses/rewards_test.py
imports: import numpy
  import tensorflow
  from texar.tf.losses.rewards import _discount_reward_tensor_2d, _discount_reward_tensor_1d, _discount_reward_py_1d, _discount_reward_py_2d, discount_reward
label_desc: Use image node_id 2 for calling the RewardTest obj's underlying member method code with example usage: obj.test_discount_reward_py_1d() without return types