docstr: Tests Black-Scholes batched Monte Carlo American option pricing.
docstr_tok: ["Tests","Black-Scholes","batched","Monte","Carlo","American","option","pricing","."]
code: def test_put_payoff_function(self):
      """Tests Black-Scholes batched Monte Carlo American option pricing."""
      dtype = tf.float64
      spot = tf.constant([100, 100], dtype=dtype)
      strikes = tf.constant([104, 90], dtype=dtype)
      is_call_option = [True, False]
      # These are expiries at which the strike prices are computed
      expiries = tf.constant([0.1, 1.0], dtype=dtype)
      volatility = 0.2 * tf.ones_like(spot)
      discount_factors = 0.95 * tf.ones_like(spot)
      seed = tf.constant([12, 42])
      # Compute option prices
      am_option_prices = utils.bs_lsm_price(
          spots=spot,
          expiry_times=expiries,
          strikes=strikes,
          volatility=volatility,
          discount_factors=discount_factors,
          num_samples=20000,
          num_exercise_times=50,
          num_calibration_samples=2000,
          is_call_option=is_call_option,
          seed=seed,
          dtype=dtype,
      )
  
      # Expected prices obtained using binomial pricer
      # tff.black_scholes.option_price_binomial
      expected_prices = [3.15257036, 2.44969723]
      self.assertAllClose(
          expected_prices, am_option_prices, rtol=1e-2, atol=1e-2
      )
  
file_path: tf-quant-finance/tf_quant_finance/experimental/pricing_platform/framework/equity_instruments/american_option/utils_test.py
imports: import tensorflow.compat.v2
  import tf_quant_finance
  from tf_quant_finance.experimental.pricing_platform.framework.equity_instruments.american_option import utils
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 1 for calling the UtilsTest obj's underlying member method code with example usage: obj.test_put_payoff_function() without return types