code: def _stratonovich_integral(
      dim, dt, sqrt_dt, dw, stratonovich_draws, order
  ):
      """Approximate Stratonovich integrals J(i, j).
  
  
  
      Args:
        dim: An integer. The dimension of the state.
        dt: A double. The time step.
        sqrt_dt: A double. The square root of dt.
        dw: A double. The Wiener increment.
        stratonovich_draws: A list of tensors corresponding to the independent
          N(0,1) random variables used in the approximation.
        order: An integer. The stratonovich_order.
  
      Returns:
        A Tensor of shape [dw.shape[0], dim, dim] corresponding to the Stratonovich
        integral for each pairwise component of the Wiener process. In other words,
        J(i,j) corresponds to an integral over W_i and W_j.
      """
      p = order - 1
      sqrt_rho_p = tf.sqrt(
          tf.constant(
              1 / 12
              - sum([1 / r**2 for r in range(1, order + 1)])
              / 2
              / _PI**2,
              dtype=dw.dtype,
          )
      )
      mu = stratonovich_draws[0]
      # Move dimensions around to make computation easier later.
      zeta = tf.transpose(stratonovich_draws[1], [2, 0, 1])
      eta = tf.transpose(stratonovich_draws[2], [2, 0, 1])
      xi = dw / sqrt_dt
      r_i = tf.stack(
          [
              tf.ones(zeta[0, ...].shape + [dim], dtype=zeta.dtype) / r
              for r in range(1, order + 1)
          ],
          0,
      )
  
      # See Eq 3.7 of section 10.3 in [2]
      # First term scaled by dt.
      value = dt * (
          _outer_prod(dw, dw) / 2
          + sqrt_rho_p
          * (_outer_prod(mu[..., p], xi) - _outer_prod(xi, mu[..., p]))
      )
  
      # Vectorized sum over r scaled by dt / 2 / pi.
      value += (
          dt
          * tf.reduce_sum(
              tf.multiply(
                  (
                      _outer_prod(zeta, _SQRT_2 * xi + eta)
                      - _outer_prod(_SQRT_2 * xi + eta, zeta)
                  ),
                  r_i,
              ),
              0,
          )
          / (2 * _PI)
      )
      return value
  
imports: import functools
  import math
  from typing import Callable, List, Optional
  import numpy
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance import utils
  from tf_quant_finance.math import custom_loops
  from tf_quant_finance.math import gradient
  from tf_quant_finance.math import random_ops
  from tf_quant_finance.models import utils
label_desc: Use image node_id 6 for calling a global function with example usage: _stratonovich_integral(dim, dt, sqrt_dt, dw, stratonovich_draws, order) and returns: value