code: def ir_swap_price(
      pay_leg_coupon_rates,
      receive_leg_coupon_rates,
      pay_leg_notional,
      receive_leg_notional,
      pay_leg_daycount_fractions,
      receive_leg_daycount_fractions,
      pay_leg_discount_factors,
      receive_leg_discount_factors,
      dtype=None,
      name=None,
  ):
      """Computes prices of a batch of interest rate swaps.
  
      #### Example
      ```python
      pay_leg_coupon_rates = [[0.1], [0.15]]
      receive_leg_coupon_rates = [[0.1, 0.2, 0.05], [0.1, 0.05, 0.2]]
      notional = 1000
      pay_leg_daycount_fractions = 0.5
      receive_leg_daycount_fractions = [[0.5, 0.5, 0.5], [0.4, 0.5, 0.6]]
      discount_factors = [[0.95, 0.9, 0.85], [0.98, 0.92, 0.88]]
  
      ir_swap_price(
          pay_leg_coupon_rates=pay_leg_coupon_rates,
          receive_leg_coupon_rates=receive_leg_coupon_rates,
          pay_leg_notional=notional,
          receive_leg_notional=notional,
          pay_leg_daycount_fractions=pay_leg_daycount_fractions,
          receive_leg_daycount_fractions=receive_leg_daycount_fractions,
          pay_leg_discount_factors=discount_factors,
          receive_leg_discount_factors=discount_factors,
          dtype=tf.float64)
      # Expected: [23.75, -40.7]
      ```
  
      Args:
        pay_leg_coupon_rates: A real `Tensor` of shape
          `batch_shape + [num_pay_cashflows]`, where `num_pay_cashflows` is the
          number of cashflows for each batch element. Coupon rates for the paying
          leg.
        receive_leg_coupon_rates: A `Tensor` of the same `dtype` as
          `pay_leg_coupon_rates` and of shape
          `batch_shape + [num_receive_cashflows]`, where `num_receive_cashflows` is
          the number of cashflows for each batch element. Coupon rates the
          receiving leg.
        pay_leg_notional: A `Tensor` of the same `dtype` as `pay_leg_coupon_rates`
          and of compatible shape. Notional amount for each cashflow.
        receive_leg_notional: A `Tensor` of the same `dtype` as
          `receive_leg_coupon_rates` and of compatible shape. Notional amount for
          each cashflow.
        pay_leg_daycount_fractions: A `Tensor` of the same `dtype` as
          `pay_leg_coupon_rates` and of compatible shape.  Year fractions for the
          coupon accrual.
        receive_leg_daycount_fractions: A `Tensor` of the same `dtype` as
          `receive_leg_coupon_rates` and of compatible shape.  Year fractions for
          the coupon accrual.
        pay_leg_discount_factors: A `Tensor` of the same `dtype` as
          `pay_leg_coupon_rates` and of compatible shape. Discount factors for each
          cashflow of the pay leg.
        receive_leg_discount_factors: A `Tensor` of the same `dtype` as
          `pay_leg_coupon_rates` and of compatible shape. Discount factors for each
          cashflow of the receive leg.
        dtype: `tf.Dtype`. If supplied the dtype for the input and output `Tensor`s.
          Default value: None which maps to the default dtype inferred from
          `pay_leg_coupon_rates`.
        name: Python str. The name to give to the ops created by this function.
          Default value: None which maps to 'equity_swap_price'.
  
      Returns:
        A `Tensor` of the same `dtype` as `pay_leg_coupon_rates` and of shape
        `batch_shape`. Present values of the interest rate swaps.
  
      """
      name = name or "ir_swap_price"
      with tf.name_scope(name):
          pay_leg_coupon_rates = tf.convert_to_tensor(
              pay_leg_coupon_rates,
              dtype=dtype,
              name="pay_leg_coupon_rates",
          )
          dtype = dtype or pay_leg_coupon_rates.dtype
          receive_leg_coupon_rates = tf.convert_to_tensor(
              receive_leg_coupon_rates,
              dtype=dtype,
              name="receive_leg_coupon_rates",
          )
          pay_leg_notional = tf.convert_to_tensor(
              pay_leg_notional, dtype=dtype, name="pay_leg_notional"
          )
          receive_leg_notional = tf.convert_to_tensor(
              receive_leg_notional,
              dtype=dtype,
              name="receive_leg_notional",
          )
          pay_leg_daycount_fractions = tf.convert_to_tensor(
              pay_leg_daycount_fractions,
              dtype=dtype,
              name="pay_leg_daycount_fractions",
          )
          receive_leg_daycount_fractions = tf.convert_to_tensor(
              receive_leg_daycount_fractions,
              dtype=dtype,
              name="receive_leg_daycount_fractions",
          )
          pay_leg_discount_factors = tf.convert_to_tensor(
              pay_leg_discount_factors,
              dtype=dtype,
              name="pay_leg_discount_factors",
          )
          receive_leg_discount_factors = tf.convert_to_tensor(
              receive_leg_discount_factors,
              dtype=dtype,
              name="receive_leg_discount_factors",
          )
  
          pay_leg_cashflows = rate_leg_cashflows(
              pay_leg_notional,
              pay_leg_daycount_fractions,
              pay_leg_coupon_rates,
          )
          receive_leg_cashflows = rate_leg_cashflows(
              receive_leg_notional,
              receive_leg_daycount_fractions,
              receive_leg_coupon_rates,
          )
          return swap_price(
              pay_leg_cashflows,
              receive_leg_cashflows,
              pay_leg_discount_factors,
              receive_leg_discount_factors,
          )
  
file_path: tf-quant-finance/tf_quant_finance/rates/analytics/swap.py
imports: import tensorflow.compat.v2
  from tf_quant_finance.rates.analytics import cashflows
label_desc: Use image node_id 4 for calling a global function with example usage: ir_swap_price(pay_leg_coupon_rates, receive_leg_coupon_rates, pay_leg_notional, receive_leg_notional, pay_leg_daycount_fractions, receive_leg_daycount_fractions, pay_leg_discount_factors, receive_leg_discount_factors, dtype, name) and returns: swap_price