code: def _analytic_valuation(
      discount_rate_fn,
      model,
      strikes,
      expiries,
      maturities,
      is_call_options,
  ):
      """Performs analytic valuation."""
      # Shape `expiry.shape`
      discount_rates_expiries = discount_rate_fn(expiries)
      discount_factor_expiries = tf.math.exp(
          -discount_rates_expiries * expiries
      )
      input_shape = tff_utils.common_shape(
          strikes, expiries, maturities
      )
      variance = _bond_option_variance(
          model,
          tf.reshape(expiries, shape=[-1]),
          tf.reshape(maturities, [-1]),
      )
      # Reshape to original shape
      variance = tf.reshape(variance, input_shape)
      discount_rates_maturities = discount_rate_fn(maturities)
      # Shape `expiries.shape`
      discount_factor_maturity = tf.math.exp(
          -discount_rates_maturities * maturities
      )
      forward_bond_price = (
          discount_factor_maturity / discount_factor_expiries
      )
  
      sqrt_variance = tf.math.sqrt(variance)
      # Shape `expiries.shape`
      log_moneyness = tf.math.log(forward_bond_price / strikes)
      d1 = tf.math.divide_no_nan(
          log_moneyness + 0.5 * variance, sqrt_variance
      )
      d2 = d1 - tf.math.sqrt(variance)
      option_value_call = discount_factor_maturity * _ncdf(
          d1
      ) - strikes * discount_factor_expiries * _ncdf(d2)
      option_value_put = strikes * discount_factor_expiries * _ncdf(
          -d2
      ) - discount_factor_maturity * _ncdf(-d1)
  
      intrinsic_value = tf.where(
          is_call_options,
          tf.math.maximum(forward_bond_price - strikes, 0),
          tf.math.maximum(strikes - forward_bond_price, 0),
      )
      option_value = tf.where(
          maturities < expiries,
          tf.zeros_like(maturities),
          tf.where(
              sqrt_variance > 0.0,
              tf.where(
                  is_call_options, option_value_call, option_value_put
              ),
              intrinsic_value,
          ),
      )
      return option_value
  
file_path: tf-quant-finance/tf_quant_finance/models/hull_white/zero_coupon_bond_option.py
imports: from typing import Callable, Union
  import numpy
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance import utils
  from tf_quant_finance.math import random
  from tf_quant_finance.models import utils
  from tf_quant_finance.models.hjm import zero_coupon_bond_option_util
  from tf_quant_finance.models.hull_white import one_factor
label_desc: Use image node_id 3 for calling a global function with example usage: _analytic_valuation(discount_rate_fn, model, strikes, expiries, maturities, is_call_options) and returns: option_value