docstr: Price for the European Call option with time-dependent volatility.
docstr_tok: ["Price","for","the","European","Call","option","with","time-dependent","volatility","."]
code: def testEuropeanCallDynamicVol(self):
      """Price for the European Call option with time-dependent volatility."""
      num_equations = 1  # Number of PDE
      num_grid_points = 1024  # Number of grid points
      dtype = np.float64
      # Build a log-uniform grid
      s_max = 300.0
      grid = grids.log_uniform_grid(
          minimums=[0.01],
          maximums=[s_max],
          sizes=[num_grid_points],
          dtype=dtype,
      )
      # Specify volatilities and interest rates for the options
      expiry = 1.0
      strike = 50.0
  
      # Volatility is of the form  `sigma**2(t) = 1 / 6 + 1 / 2 * t**2`.
      def second_order_coeff_fn(t, location_grid):
          return [
              [(1.0 / 6 + t**2 / 2) * tf.square(location_grid[0]) / 2]
          ]
  
      @dirichlet
      def lower_boundary_fn(t, location_grid):
          del t, location_grid
          return 0
  
      @dirichlet
      def upper_boundary_fn(t, location_grid):
          del t
          return location_grid[0][-1] - strike
  
      final_values = tf.nn.relu(grid[0] - strike)
      # Broadcast to the shape of value dimension, if necessary.
      final_values += tf.zeros(
          [num_equations, num_grid_points], dtype=dtype
      )
      # Estimate European call option price
      estimate = fd_solvers.solve_backward(
          start_time=expiry,
          end_time=0,
          coord_grid=grid,
          values_grid=final_values,
          num_steps=None,
          start_step_count=0,
          time_step=tf.constant(0.01, dtype=dtype),
          one_step_fn=crank_nicolson_step(),
          boundary_conditions=[(lower_boundary_fn, upper_boundary_fn)],
          values_transform_fn=None,
          second_order_coeff_fn=second_order_coeff_fn,
          dtype=dtype,
      )[0]
  
      value_grid = self.evaluate(estimate)[0, :]
      # Get two grid locations (correspond to spot 51.9537332 and 106.25407758,
      # respectively).
      loc_1 = 849
      # True call option price (obtained using black_scholes_price function)
      call_price = 12.582092
      self.assertAllClose(
          call_price, value_grid[loc_1], rtol=1e-02, atol=1e-02
      )
  
imports: import math
  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 11 for calling the ParabolicEquationStepperTest obj's underlying member method code with example usage: obj.testEuropeanCallDynamicVol() and returns: list, int, unknown