code: def test_zero_coupon_bond(self, dtype):
      cashflows = [
          # 6 months bond with no coupons.
          np.array([1020], dtype=dtype),
          # 1 year bond with 5% semi-annual coupon.
          np.array([25, 1025], dtype=dtype),
          # 2 year bond with 8% annual coupon.
          np.array([80, 1080], dtype=dtype),
          # 3 year bond with 3% annual coupon.
          np.array([30, 30, 1030], dtype=dtype),
      ]
      cashflow_times = [
          np.array([0.5], dtype=dtype),
          np.array([0.5, 1.0], dtype=dtype),
          np.array([1.0, 2.0], dtype=dtype),
          np.array([1.0, 2.0, 3.0], dtype=dtype),
      ]
      pvs = np.array([1000.0, 1000.0, 1000.0, 1000.0], dtype=dtype)
      # We can calculate discount rates going step-by-step.
      r1 = -math.log(pvs[0] / cashflows[0][0]) / cashflow_times[0]
      r2 = -(
          math.log(
              (
                  pvs[1]
                  - cashflows[1][0]
                  * math.exp(-r1 * cashflow_times[1][0])
              )
              / cashflows[1][1]
          )
          / cashflow_times[1][1]
      )
      r3 = -(
          math.log(
              (
                  pvs[2]
                  - cashflows[2][0]
                  * math.exp(-r2 * cashflow_times[2][0])
              )
              / cashflows[2][1]
          )
          / cashflow_times[2][1]
      )
      r4 = -(
          math.log(
              (
                  pvs[3]
                  - cashflows[3][0]
                  * math.exp(-r2 * cashflow_times[3][0])
                  - cashflows[3][1]
                  * math.exp(-r3 * cashflow_times[3][1])
              )
              / cashflows[3][2]
          )
          / cashflow_times[3][2]
      )
      true_discount_rates = np.array(
          [r1.item(), r2, r3, r4], dtype=dtype
      )
  
      results = self.evaluate(
          bond_curve.bond_curve(
              cashflows,
              cashflow_times,
              pvs,
              validate_args=True,
              dtype=dtype,
          )
      )
      with self.subTest("Converged"):
          self.assertTrue(results.converged)
      with self.subTest("NotFailed"):
          self.assertFalse(results.failed)
      with self.subTest("NumIterations"):
          self.assertEqual(results.iterations, 4)
      with self.subTest("DiscountRates"):
          np.testing.assert_allclose(
              results.discount_rates, true_discount_rates, atol=1e-6
          )
      with self.subTest("Times"):
          np.testing.assert_allclose(
              results.times, [0.5, 1.0, 2.0, 3.0], atol=1e-6
          )
  
imports: import math
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow.python.framework import test_util
  from tf_quant_finance.rates.hagan_west import bond_curve
  from tf_quant_finance.rates.hagan_west import monotone_convex
label_desc: Use image node_id 10 for calling the BondCurveTest obj's underlying member method code with example usage: obj.test_zero_coupon_bond(dtype) without return types