class_docstr: Represents a batch of cashflows indexed to a CMS rate.
  
  #### Example:
  ```python
  import numpy as np
  import tensorflow as tf
  import tf_quant_finance as tff
  dates = tff.datetime
  instruments = tff.experimental.instruments
  
  start_date = dates.convert_to_date_tensor([(2021, 1, 1)])
  maturity_date = dates.convert_to_date_tensor([(2023, 1, 1)])
  valuation_date = dates.convert_to_date_tensor([(2021, 1, 1)])
  p3m = dates.periods.months(3)
  p6m = dates.periods.months(6)
  p1y = dates.periods.year()
  fix_spec = instruments.FixedCouponSpecs(
      coupon_frequency=p6m,
      currency='usd',
      notional=1.,
      coupon_rate=0.0,  # Not needed
      daycount_convention=instruments.DayCountConvention.ACTUAL_365,
      businessday_rule=dates.BusinessDayConvention.NONE)
  flt_spec = instruments.FloatCouponSpecs(
      coupon_frequency=p3m,
      reference_rate_term=p3m,
      reset_frequency=p3m,
      currency='usd',
      notional=1.,
      businessday_rule=dates.BusinessDayConvention.NONE,
      coupon_basis=0.,
      coupon_multiplier=1.,
      daycount_convention=instruments.DayCountConvention.ACTUAL_365)
  cms_spec = instruments.CMSCouponSpecs(
      coupon_frequency=p3m,
      tenor=p1y,
      float_leg=flt_spec,
      fixed_leg=fix_spec,
      notional=1.,
      coupon_basis=0.,
      coupon_multiplier=1.,
      businessday_rule=None,
      daycount_convention=instruments.DayCountConvention.ACTUAL_365)
  
  cms = instruments.CMSCashflowStream(
      start_date, maturity_date, [cms_spec], dtype=dtype)
  
  curve_dates = valuation_date + dates.periods.years([0, 1, 2, 3, 5])
  reference_curve = instruments.RateCurve(
      curve_dates,
      np.array([
          0.02, 0.02, 0.025, 0.03, 0.035
      ], dtype=np.float64),
      valuation_date=valuation_date,
      dtype=np.float64)
  market = instruments.InterestRateMarket(
      reference_curve=reference_curve, discount_curve=reference_curve)
  
  price = cms.price(valuation_date, market)
  # Expected result: 55512.6295434207
  ```
class_docstr_tok: ["Represents","a","batch","of","cashflows","indexed","to","a","CMS","rate",".","#","#","#","#","Example",":","``","`","python","import","numpy","as","np","import","tensorflow","as","tf","import","tf_quant_finance","as","tff","dates","=","tff.datetime","instruments","=","tff.experimental.instruments","start_date","=","dates.convert_to_date_tensor","(","[","(","2021",",","1",",","1",")","]",")","maturity_date","=","dates.convert_to_date_tensor","(","[","(","2023",",","1",",","1",")","]",")","valuation_date","=","dates.convert_to_date_tensor","(","[","(","2021",",","1",",","1",")","]",")","p3m","=","dates.periods.months","(","3",")","p6m","=","dates.periods.months","(","6",")","p1y","=","dates.periods.year","(",")","fix_spec","=","instruments.FixedCouponSpecs","(","coupon_frequency=p6m",",","currency='usd","'",",","notional=1.",",","coupon_rate=0.0",",","#","Not","needed","daycount_convention=instruments.DayCountConvention.ACTUAL_365",",","businessday_rule=dates.BusinessDayConvention.NONE",")","flt_spec","=","instruments.FloatCouponSpecs","(","coupon_frequency=p3m",",","reference_rate_term=p3m",",","reset_frequency=p3m",",","currency='usd","'",",","notional=1.",",","businessday_rule=dates.BusinessDayConvention.NONE",",","coupon_basis=0.",",","coupon_multiplier=1.",",","daycount_convention=instruments.DayCountConvention.ACTUAL_365",")","cms_spec","=","instruments.CMSCouponSpecs","(","coupon_frequency=p3m",",","tenor=p1y",",","float_leg=flt_spec",",","fixed_leg=fix_spec",",","notional=1.",",","coupon_basis=0.",",","coupon_multiplier=1.",",","businessday_rule=None",",","daycount_convention=instruments.DayCountConvention.ACTUAL_365",")","cms","=","instruments.CMSCashflowStream","(","start_date",",","maturity_date",",","[","cms_spec","]",",","dtype=dtype",")","curve_dates","=","valuation_date","+","dates.periods.years","(","[","0",",","1",",","2",",","3",",","5","]",")","reference_curve","=","instruments.RateCurve","(","curve_dates",",","np.array","(","[","0.02",",","0.02",",","0.025",",","0.03",",","0.035","]",",","dtype=np.float64",")",",","valuation_date=valuation_date",",","dtype=np.float64",")","market","=","instruments.InterestRateMarket","(","reference_curve=reference_curve",",","discount_curve=reference_curve",")","price","=","cms.price","(","valuation_date",",","market",")","#","Expected","result",":","55512.6295434207","``","`"]
docstr: Returns the present value of the stream on the valuation date.
  
  Args:
    valuation_date: A scalar `DateTensor` specifying the date on which
      valuation is being desired.
    market: A namedtuple of type `InterestRateMarket` which contains the
      necessary information for pricing the cashflow stream.
    model: An optional input of type `InterestRateModelType` to specify which
      model to use for pricing.
      Default value: `None` in which case `NORMAL_RATE` model is used.
    pricing_context: An optional input to provide additional parameters (such
      as model parameters) relevant for pricing.
    name: Python str. The name to give to the ops created by this function.
      Default value: `None` which maps to 'price'.
  
  Returns:
    A Rank 1 `Tensor` of real type containing the modeled price of each stream
    contract based on the input market data.
docstr_tok: ["Returns","the","present","value","of","the","stream","on","the","valuation","date",".","Args",":","valuation_date",":","A","scalar","`","DateTensor","`","specifying","the","date","on","which","valuation","is","being","desired",".","market",":","A","namedtuple","of","type","`","InterestRateMarket","`","which","contains","the","necessary","information","for","pricing","the","cashflow","stream",".","model",":","An","optional","input","of","type","`","InterestRateModelType","`","to","specify","which","model","to","use","for","pricing",".","Default","value",":","`","None","`","in","which","case","`","NORMAL_RATE","`","model","is","used",".","pricing_context",":","An","optional","input","to","provide","additional","parameters","(","such","as","model","parameters",")","relevant","for","pricing",".","name",":","Python","str",".","The","name","to","give","to","the","ops","created","by","this","function",".","Default","value",":","`","None","`","which","maps","to","'price","'",".","Returns",":","A","Rank","1","`","Tensor","`","of","real","type","containing","the","modeled","price","of","each","stream","contract","based","on","the","input","market","data","."]
code: def price(
      self,
      valuation_date,
      market,
      model=None,
      pricing_context=None,
      name=None,
  ):
      """Returns the present value of the stream on the valuation date.
  
      Args:
        valuation_date: A scalar `DateTensor` specifying the date on which
          valuation is being desired.
        market: A namedtuple of type `InterestRateMarket` which contains the
          necessary information for pricing the cashflow stream.
        model: An optional input of type `InterestRateModelType` to specify which
          model to use for pricing.
          Default value: `None` in which case `NORMAL_RATE` model is used.
        pricing_context: An optional input to provide additional parameters (such
          as model parameters) relevant for pricing.
        name: Python str. The name to give to the ops created by this function.
          Default value: `None` which maps to 'price'.
  
      Returns:
        A Rank 1 `Tensor` of real type containing the modeled price of each stream
        contract based on the input market data.
      """
  
      name = name or (self._name + "_price")
      with tf.name_scope(name):
          valuation_date = dates.convert_to_date_tensor(valuation_date)
          discount_curve = market.discount_curve
          past_fixing = rc.get_rate_index(
              market,
              self._start_date,
              rc.RateIndexType.SWAP,
              dtype=self._dtype,
          )
          past_fixing = tf.repeat(
              tf.convert_to_tensor(past_fixing, dtype=self._dtype),
              self._num_cashflows,
          )
  
          discount_factors = discount_curve.get_discount_factor(
              self._payment_dates
          )
          cms_rates = self._swap.par_rate(valuation_date, market, model)
  
          cms_rates = tf.where(
              self._daycount_fractions > 0.0,
              cms_rates,
              tf.zeros_like(cms_rates),
          )
          # If coupon end date is before the valuation date, the payment is in the
          # past. If valuation date is between coupon start date and coupon end
          # date, then the rate has been fixed but not paid. Otherwise the rate is
          # not fixed and should be read from the curve.
          cms_rates = tf.where(
              self._coupon_end_dates < valuation_date,
              tf.constant(0.0, dtype=self._dtype),
              tf.where(
                  self._coupon_start_dates < valuation_date,
                  past_fixing,
                  cms_rates,
              ),
          )
          cms_rates = self._adjust_convexity(
              valuation_date,
              market,
              model,
              pricing_context,
              cms_rates,
              discount_factors,
          )
  
          coupon_rate = self._coupon_multiplier * (
              cms_rates + self._coupon_basis
          )
  
          cashflow_pvs = self._notional * (
              self._daycount_fractions * coupon_rate * discount_factors
          )
          return tf.math.segment_sum(cashflow_pvs, self._contract_index)
  
imports: import itertools
  import tensorflow.compat.v2
  import tensorflow_probability
  from tf_quant_finance import black_scholes
  from tf_quant_finance import datetime
  from tf_quant_finance.experimental.instruments import cashflow_stream
  from tf_quant_finance.experimental.instruments import interest_rate_swap
  from tf_quant_finance.experimental.instruments import rates_common
  from tf_quant_finance.math import integration
label_desc: Use image node_id 2 for calling the CMSCashflowStream obj's underlying member method code with example usage: obj.price(valuation_date, market, model, pricing_context, name) and returns: tf