docstr: Tests solving 2d diffusion equation with Dirichlet boundary conditions.
  
  The equation is `u_{t} + u_{xx} + 2 u_{yy} = 0`.
  The final condition is `u(t=1, x, y) = e * sin(x/sqrt(2)) * cos(y / 2)`.
  The following function satisfies this PDE and final condition:
  `u(t, x, y) = exp(t) * sin(x / sqrt(2)) * cos(y / 2)`.
  We impose Dirichlet boundary conditions using this function:
  `u(t, x_min, y) = exp(t) * sin(x_min / sqrt(2)) * cos(y / 2)`, etc.
  The other tests below are similar, but with other types of boundary
  conditions.
docstr_tok: ["Tests","solving","2d","diffusion","equation","with","Dirichlet","boundary","conditions",".","The","equation","is","`","u_","{","t","}","+","u_","{","xx","}","+","2","u_","{","yy","}","=","0","`",".","The","final","condition","is","`","u","(","t=1",",","x",",","y",")","=","e","*","sin","(","x\/sqrt","(","2",")",")","*","cos","(","y","\/","2",")","`",".","The","following","function","satisfies","this","PDE","and","final","condition",":","`","u","(","t",",","x",",","y",")","=","exp","(","t",")","*","sin","(","x","\/","sqrt","(","2",")",")","*","cos","(","y","\/","2",")","`",".","We","impose","Dirichlet","boundary","conditions","using","this","function",":","`","u","(","t",",","x_min",",","y",")","=","exp","(","t",")","*","sin","(","x_min","\/","sqrt","(","2",")",")","*","cos","(","y","\/","2",")","`",",","etc",".","The","other","tests","below","are","similar",",","but","with","other","types","of","boundary","conditions","."]
code: def testAnisotropicDiffusion_WithDirichletBoundaries(self):
      """Tests solving 2d diffusion equation with Dirichlet boundary conditions.
  
      The equation is `u_{t} + u_{xx} + 2 u_{yy} = 0`.
      The final condition is `u(t=1, x, y) = e * sin(x/sqrt(2)) * cos(y / 2)`.
      The following function satisfies this PDE and final condition:
      `u(t, x, y) = exp(t) * sin(x / sqrt(2)) * cos(y / 2)`.
      We impose Dirichlet boundary conditions using this function:
      `u(t, x_min, y) = exp(t) * sin(x_min / sqrt(2)) * cos(y / 2)`, etc.
      The other tests below are similar, but with other types of boundary
      conditions.
      """
      time_step = 0.01
      final_t = 1
      x_min = -20
      x_max = 20
      y_min = -10
      y_max = 10
  
      grid = grids.uniform_grid(
          minimums=[y_min, x_min],
          maximums=[y_max, x_max],
          sizes=[201, 301],
          dtype=tf.float32,
      )
      ys = self.evaluate(grid[0])
      xs = self.evaluate(grid[1])
  
      def second_order_coeff_fn(t, location_grid):
          del t, location_grid
          return [[2, None], [None, 1]]
  
      @dirichlet
      def lower_bound_x(t, location_grid):
          del location_grid
          return tf.exp(t) * np.sin(x_min / _SQRT2) * tf.sin(ys / 2)
  
      @dirichlet
      def upper_bound_x(t, location_grid):
          del location_grid
          return tf.exp(t) * np.sin(x_max / _SQRT2) * tf.sin(ys / 2)
  
      @dirichlet
      def lower_bound_y(t, location_grid):
          del location_grid
          return tf.exp(t) * tf.sin(xs / _SQRT2) * np.sin(y_min / 2)
  
      @dirichlet
      def upper_bound_y(t, location_grid):
          del location_grid
          return tf.exp(t) * tf.sin(xs / _SQRT2) * np.sin(y_max / 2)
  
      expected = np.outer(np.sin(ys / 2), np.sin(xs / _SQRT2))
  
      final_values = tf.expand_dims(
          tf.constant(
              np.outer(np.sin(ys / 2), np.sin(xs / _SQRT2))
              * np.exp(final_t),
              dtype=tf.float32,
          ),
          axis=0,
      )
      bound_cond = [
          (lower_bound_y, upper_bound_y),
          (lower_bound_x, upper_bound_x),
      ]
      step_fn = douglas_adi_step(theta=0.5)
      result = fd_solvers.solve_backward(
          start_time=final_t,
          end_time=0,
          coord_grid=grid,
          values_grid=final_values,
          time_step=time_step,
          one_step_fn=step_fn,
          boundary_conditions=bound_cond,
          second_order_coeff_fn=second_order_coeff_fn,
          dtype=grid[0].dtype,
      )
  
      self._assertClose(expected, result)
  
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 12 for calling the MultidimParabolicEquationStepperTest obj's underlying member method code with example usage: obj.testAnisotropicDiffusion_WithDirichletBoundaries() and returns: list, unknown, unknown, unknown, unknown