class_docstr: Tests reward related functions.
      
docstr: Tests :func:`texar.tf.losses.rewards._discount_reward_py_2d`
          
code: def test_discount_reward_py_2d(self):
      """Tests :func:`texar.tf.losses.rewards._discount_reward_py_2d`"""
      reward = np.ones([2, 10], dtype=np.float64)
      sequence_length = [5, 10]
  
      discounted_reward_1 = _discount_reward_py_2d(
          reward, sequence_length, discount=1.0
      )
  
      discounted_reward_2 = _discount_reward_py_2d(
          reward, sequence_length, discount=0.1
      )
  
      r = discounted_reward_1
      for i in range(10):
          if i < 5:
              self.assertEqual(r[0, i], 5 - i)
          else:
              self.assertEqual(r[0, i], 0)
          self.assertEqual(r[1, i], 10 - i)
  
      r = discounted_reward_2
      for i in range(10):
          if i < 5:
              self.assertEqual(
                  r[0, i], int(11111.0 / 10**i) / 10 ** (4 - i)
              )
          else:
              self.assertEqual(r[0, i], 0)
          self.assertEqual(
              r[1, i], int(1111111111.0 / 10**i) / 10 ** (9 - 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 4 for calling the RewardTest obj's underlying member method code with example usage: obj.test_discount_reward_py_2d() without return types