class_docstr: Handles the various pricing functions for asian options.
class_docstr_tok: ["Handles","the","various","pricing","functions","for","asian","options","."]
docstr: Calculates tilde{omega}_k(s, w) (eq. (19) from the referenced paper).
docstr_tok: ["Calculates","tilde","{","omega","}","_k","(","s",",","w",")","(","eq",".","(","19",")","from","the","referenced","paper",")","."]
code: def omega_tilde_k(self, s, w, z_k_tensor):
      """Calculates tilde{omega}_k(s, w) (eq. (19) from the referenced paper)."""
      omega_tilde = self.omega_k(s, w)
      mr_v2 = self.mean_reversion / tf.math.pow(self.volvol, 2)
      x0 = utils.get_shape(omega_tilde)[-2] - 1
      # If shape of omega_tilde is known, use TensorArray of known shape
      if isinstance(x0, int):
          ta = tf.TensorArray(
              omega_tilde.dtype, size=x0 + 1, clear_after_read=False
          )
      else:
          # Otherwise, use dynamically shaped TensorArray
          ta = tf.TensorArray(
              omega_tilde.dtype, size=0, dynamic_size=True
          )
      last_row = omega_tilde[..., 0, :]
  
      condition = lambda q, ta, last_row: q >= 0
  
      def modify_row(q, row, last_row):
          d_tau = tf.expand_dims(self.d_tau_k[q], axis=-1)
          z_k = z_k_tensor[q]
  
          return (
              row
              + mr_v2
              - (
                  2
                  * self.f_tilde(z_k, last_row, d_tau)
                  / (
                      self.f(z_k, last_row, d_tau)
                      * tf.math.pow(self.volvol, 2)
                  )
              )
          )
  
      def body(q, ta, last_row):
          # Use tf.where here for better vecotrization
          row = tf.where(
              q < x0,
              modify_row(
                  tf.minimum(q, x0 - 1),
                  omega_tilde[..., tf.minimum(q, x0 - 1), :],
                  last_row,
              ),
              omega_tilde[..., q, :],
          )
          ta = ta.write(q, row)
          last_row = row
          return (q - 1, ta, last_row)
  
      _, r, _ = tf.while_loop(condition, body, [x0, ta, last_row])
      # Shape batch_shape + [num_sampling_times - fixing_count + 2]
      # + [num_integration_points]
      return r.stack()
  
file_path: tf-quant-finance/tf_quant_finance/models/heston/approximations/asian_prices.py
imports: import numpy
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance import utils
  from tf_quant_finance.black_scholes import AveragingFrequency
  from tf_quant_finance.black_scholes import AveragingType
  from tf_quant_finance.math import integration
label_desc: Use image node_id 6 for calling the _AsianPricesHandler obj's underlying member method code with example usage: obj.omega_tilde_k(s, w, z_k_tensor) and returns: r, unknown, unknown,  ta,  last_row