code: def test_compare_monte_carlo_to_backward_pde(self):
      dtype = tf.float64
      mean_reversion = 0.3
      theta = 0.05
      volvol = 0.02
      rho = 0.1
      maturity_time = 1.0
      initial_log_spot = 3.0
      initial_vol = 0.05
      strike = 15
      discounting = 0.5
  
      heston = HestonModel(
          mean_reversion=mean_reversion,
          theta=theta,
          volvol=volvol,
          rho=rho,
          dtype=dtype,
      )
      initial_state = np.array([initial_log_spot, initial_vol])
      samples = heston.sample_paths(
          times=[maturity_time / 2, maturity_time],
          initial_state=initial_state,
          time_step=0.01,
          num_samples=1000,
          random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
          seed=[1, 42],
      )
      self.assertEqual(samples.shape, [1000, 2, 2])
      log_spots = samples[:, -1, 0]
      monte_carlo_price = tf.constant(
          np.exp(-discounting * maturity_time), dtype=dtype
      ) * tf.math.reduce_mean(
          tf.nn.relu(tf.math.exp(log_spots) - strike)
      )
  
      s_min, s_max = 2, 4
      v_min, v_max = 0.03, 0.07
      grid_size_s, grid_size_v = 101, 101
      time_step = 0.01
  
      grid = grids.uniform_grid(
          minimums=[s_min, v_min],
          maximums=[s_max, v_max],
          sizes=[grid_size_s, grid_size_v],
          dtype=dtype,
      )
  
      s_mesh, _ = tf.meshgrid(grid[0], grid[1], indexing="ij")
      final_value_grid = tf.nn.relu(tf.math.exp(s_mesh) - strike)
      value_grid = heston.fd_solver_backward(
          start_time=1.0,
          end_time=0.0,
          coord_grid=grid,
          values_grid=final_value_grid,
          time_step=time_step,
          discounting=lambda *args: discounting,
      )[0]
      pde_price = value_grid[int(grid_size_s / 2), int(grid_size_v / 2)]
  
      self.assertAllClose(
          monte_carlo_price, pde_price, atol=0.1, rtol=0.1
      )
  
file_path: tf-quant-finance/tf_quant_finance/models/heston/heston_model_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 8 for calling the HestonModelTest obj's underlying member method code with example usage: obj.test_compare_monte_carlo_to_backward_pde() without return types