code: def test_validate_args(self):
      dtype = np.float64
  
      observed_prices = np.array(
          [
              [
                  20.09689284,
                  10.91953054,
                  4.25012702,
                  1.11561839,
                  0.20815853,
              ],
              [
                  3.34813209,
                  6.03578711,
                  10.2874194,
                  16.26824328,
                  23.73850935,
              ],
          ],
          dtype=dtype,
      )
  
      strikes = np.array(
          [
              [80.0, 90.0, 100.0, 110.0, 120.0],
              [80.0, 90.0, 100.0, 110.0, 120.0],
          ],
          dtype=dtype,
      )
      expiries = np.array([[0.5], [1.0]], dtype=dtype)
      forwards = 100.0
      is_call_options = np.array([[True], [False]])
  
      beta = np.array([0.5, 0.5], dtype=dtype)
  
      # Fails because `volvol` is outside the limits.
      with self.assertRaises(tf.errors.InvalidArgumentError):
          _, is_converged, _ = tff.models.sabr.calibration(
              prices=observed_prices,
              strikes=strikes,
              expiries=expiries,
              forwards=forwards,
              is_call_options=is_call_options,
              beta=beta,
              calibrate_beta=False,
              volvol=np.array([1.0, 12.0], dtype=dtype),
              volvol_lower_bound=0.0,
              volvol_upper_bound=10.0,
              rho=np.array([0.0, 0.0], dtype=dtype),
              rho_lower_bound=-0.75,
              rho_upper_bound=0.75,
              validate_args=True,
          )
          self.evaluate(is_converged)
  
      # Fails because `rho` exceeds its expected bounds.
      with self.assertRaises(tf.errors.InvalidArgumentError):
          _, is_converged, _ = tff.models.sabr.calibration(
              prices=observed_prices,
              strikes=strikes,
              expiries=expiries,
              forwards=forwards,
              is_call_options=is_call_options,
              beta=beta,
              calibrate_beta=False,
              volvol=np.array([1.0, 1.0], dtype=dtype),
              volvol_lower_bound=0.0,
              volvol_upper_bound=10.0,
              rho=np.array([0.0, 0.76], dtype=dtype),
              rho_lower_bound=-0.75,
              rho_upper_bound=0.75,
              validate_args=True,
          )
          self.evaluate(is_converged)
  
      # Arguments are okay.
      _, is_converged, _ = tff.models.sabr.calibration(
          prices=observed_prices,
          strikes=strikes,
          expiries=expiries,
          forwards=forwards,
          is_call_options=is_call_options,
          beta=beta,
          calibrate_beta=False,
          volvol=np.array([1.0, 1.0], dtype=dtype),
          volvol_lower_bound=0.0,
          volvol_upper_bound=10.0,
          rho=np.array([0.0, 0.0], dtype=dtype),
          rho_lower_bound=-0.75,
          rho_upper_bound=0.75,
          validate_args=True,
      )
      is_converged = self.evaluate(is_converged)
      self.assertTrue(all(is_converged))
  
file_path: tf-quant-finance/tf_quant_finance/models/sabr/approximations/calibration_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 4 for calling the CalibrationTest obj's underlying member method code with example usage: obj.test_validate_args() without return types