docstr: Tests dupire_local_volatility with a flat vol surface.
docstr_tok: ["Tests","dupire_local_volatility","with","a","flat","vol","surface","."]
code: def test_dupire_with_flat_surface(self, dupire_local_volatility):
      """Tests dupire_local_volatility with a flat vol surface."""
      dim = 1
      dtype = tf.float64
      (
          val_date,
          expiries,
          expiry_times,
          strikes,
          iv,
          initial_spot,
      ) = build_tensors(dim)
      vs = build_volatility_surface(
          val_date, expiry_times, expiries, strikes, iv, dtype=dtype
      )
      dividend_yield = [0.0]
      r = tf.convert_to_tensor([0.0], dtype=dtype)
      discount_factor_fn = lambda t: tf.math.exp(-r * t)
  
      times = tf.convert_to_tensor([1.0, 2.0, 3.0], dtype=dtype)
      spots = tf.reshape(
          tf.convert_to_tensor([1.0, 2.0, 3.0], dtype=dtype), [3, 1]
      )
      dupire_vols = dupire_local_volatility(
          times,
          spots,
          initial_spot,
          vs.volatility,
          discount_factor_fn,
          dividend_yield,
      )
      true_vols = [0.1] * 3
      for i in range(3):
          self.assertAllClose(dupire_vols[:, i], true_vols)
  
imports: import functools
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tf_quant_finance.experimental.local_volatility import local_volatility_model
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 4 for calling the LocalVolatilityTest obj's underlying member method code with example usage: obj.test_dupire_with_flat_surface(dupire_local_volatility) without return types