code: def _bond_option_variance(model, option_expiry, bond_maturity):
      """Computes black equivalent variance for bond options.
  
      Black equivalent variance is defined as the variance to use in the Black
      formula to obtain the model implied price of European bond options.
  
      Args:
        model: An instance of `VectorHullWhiteModel`.
        option_expiry: A rank 1 `Tensor` of real dtype specifying the time to
          expiry of each option.
        bond_maturity: A rank 1 `Tensor` of real dtype specifying the time to
          maturity of underlying zero coupon bonds.
  
      Returns:
        A rank 1 `Tensor` of same dtype and shape as the inputs with computed
        Black-equivalent variance for the underlying options.
      """
      # pylint: disable=protected-access
      if model._sample_with_generic:
          raise ValueError(
              "The paramerization of `mean_reversion` and/or "
              "`volatility` does not support analytic computation "
              "of bond option variance."
          )
      mean_reversion = model.mean_reversion(option_expiry)
      volatility = model.volatility(option_expiry)
  
      # Shape [num_times]
      var_between_vol_knots = model._variance_int(
          model._padded_knots,
          model._jump_locations,
          model._jump_values_vol,
          model._jump_values_mr,
      )[0]
      # Shape [num_times]
      varx_at_vol_knots = tf.concat(
          [
              tf.zeros([1], dtype=var_between_vol_knots.dtype),
              utils.cumsum_using_matvec(var_between_vol_knots),
          ],
          axis=-1,
      )
      # Shape [num_times + 1]
      time_index = tf.searchsorted(
          model._jump_locations[0], option_expiry
      )
      # Shape [1, num_times + 1]
      vn = tf.concat(
          [model._zero_padding, model._jump_locations], axis=-1
      )
  
      # Shape [num_times]
      var_expiry = model._variance_int(
          tf.gather(vn, time_index, axis=-1),
          option_expiry,
          volatility,
          mean_reversion,
      )[0]
      var_expiry = var_expiry + tf.gather(varx_at_vol_knots, time_index)
      var_expiry = (
          var_expiry
          * (
              tf.math.exp(-mean_reversion * option_expiry)
              - tf.math.exp(-mean_reversion * bond_maturity)
          )
          ** 2
          / mean_reversion**2
      )
      # gpylint: enable=protected-access
      # shape [num_times]
      return var_expiry
  
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 4 for calling a global function with example usage: _bond_option_variance(model, option_expiry, bond_maturity) and returns: var_expiry