class_docstr: Tests for the variance_swaps module.
class_docstr_tok: ["Tests","for","the","variance_swaps","module","."]
code: def test_variance_swap_fair_strike_supports_batching(
      self, validate_args
  ):
      dtype = tf.float64
      batch_call_strikes = tf.repeat(
          tf.expand_dims(tf.range(100, 120, 5, dtype=dtype), 0),
          3,
          axis=0,
      )
      batch_put_strikes = tf.repeat(
          tf.expand_dims(tf.range(100, 80, -5, dtype=dtype), 0),
          3,
          axis=0,
      )
      batch_vols = 0.2 * tf.ones((3, 4), dtype=dtype)
      batch_shape = (3,)
      reference_strikes = 100.0 * tf.ones(batch_shape, dtype=dtype)
      batch_expiries = tf.constant([0.25, 0.5, 1.0], dtype=dtype)
      discount_rates = 0.05 * tf.ones(batch_shape, dtype=dtype)
      batch_variance_price = self.evaluate(
          tff.black_scholes.variance_swap_fair_strike(
              batch_put_strikes,
              batch_vols,
              batch_call_strikes,
              batch_vols,
              batch_expiries,
              discount_rates,
              reference_strikes,
              reference_strikes,
              validate_args=validate_args,
              dtype=dtype,
          )
      )
  
      self.assertEqual(batch_variance_price.shape, batch_shape)
      for i in range(3):
          row_variance_price = self.evaluate(
              tff.black_scholes.variance_swap_fair_strike(
                  batch_put_strikes[i, :],
                  batch_vols[i, :],
                  batch_call_strikes[i, :],
                  batch_vols[i, :],
                  batch_expiries[i],
                  discount_rates[i],
                  reference_strikes[i],
                  reference_strikes[i],
                  dtype=tf.float64,
              )
          )
          self.assertAllEqual(
              row_variance_price, batch_variance_price[i]
          )
  
file_path: tf-quant-finance/tf_quant_finance/black_scholes/variance_swaps_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tf_quant_finance.black_scholes import variance_swaps
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 5 for calling the VarianceSwapsTest obj's underlying member method code with example usage: obj.test_variance_swap_fair_strike_supports_batching(validate_args) without return types