class_docstr: Represents a batch of fixed stream of cashflows.
class_docstr_tok: ["Represents","a","batch","of","fixed","stream","of","cashflows","."]
docstr: Initializes a batch of fixed cashflow streams.
  
  Args:
    coupon_spec: An instance of `FixedCouponSpecs` specifying the
      details of the coupon payment for the cashflow stream.
    discount_curve_type: An instance of `CurveType` or a list of those.
      If supplied as a list and `discount_curve_mask` is not supplied,
      the size of the list should be the same as the number of priced
      instruments. Defines discount curves for the instruments.
    start_date: A `DateTensor` of `batch_shape` specifying the starting dates
      of the accrual of the first coupon of the cashflow stream. The shape of
      the input correspond to the number of streams being created.
      When passed as an integet `Tensor`, should be of shape
      `batch_shape + [3]` and contain `[year, month, day]` for each date.
      Either this of `schedule` should be supplied
      Default value: `None`
    end_date: A `DateTensor` of `batch_shape`specifying the end dates for
      accrual of the last coupon in each cashflow stream. The shape of the
      input should be the same as that of `start_date`.
      Either this of `schedule` should be supplied
      When passed as an integet `Tensor`, should be of shape
      `batch_shape + [3]` and contain `[year, month, day]` for each date.
      Default value: `None`
    discount_curve_mask: An optional integer `Tensor` of values ranging from
      `0` to `len(discount_curve_type) - 1` and of shape `batch_shape`.
      Identifies a mapping between `discount_curve_type` list and the
      underlying instruments.
      Default value: `None`.
    first_coupon_date: An optional `DateTensor` specifying the payment dates
      of the first coupon of the cashflow stream. Use this input for cashflows
      with irregular first coupon. Should be of the same shape as
      `start_date`.
      When passed as an integet `Tensor`, should be of shape
      `batch_shape + [3]` and contain `[year, month, day]` for each date.
      Default value: None which implies regular first coupon.
    penultimate_coupon_date: An optional `DateTensor` specifying the payment
      dates of the penultimate (next to last) coupon of the cashflow
      stream. Use this input for cashflows with irregular last coupon.
      Should be of the same shape as `end_date`.
      When passed as an integet `Tensor`, should be of shape
      `batch_shape + [3]` and contain `[year, month, day]` for each date.
      Default value: None which implies regular last coupon.
    schedule_fn: A callable that accepts `start_date`, `end_date`,
      `coupon_frequency`, `settlement_days`, `first_coupon_date`, and
      `penultimate_coupon_date` as `Tensor`s and returns coupon payment
      days.
      Default value: `None`.
    schedule: A `DateTensor` of coupon payment dates including the start and
      end dates of the cashflows.
      Default value: `None`.
    dtype: `tf.Dtype` of the input and output real `Tensor`s.
      Default value: None which maps to the default dtype inferred by
      TensorFlow.
    name: Python str. The name to give to the ops created by this class.
      Default value: `None` which maps to 'fixed_cashflow_stream'.
code: def __init__(
      self,
      coupon_spec: coupon_specs.FixedCouponSpecs,
      discount_curve_type: Union[_CurveType, List[_CurveType]],
      start_date: types.DateTensor = None,
      end_date: types.DateTensor = None,
      discount_curve_mask: types.IntTensor = None,
      first_coupon_date: Optional[types.DateTensor] = None,
      penultimate_coupon_date: Optional[types.DateTensor] = None,
      schedule_fn: Optional[Callable[..., Any]] = None,
      schedule: Optional[types.DateTensor] = None,
      dtype: Optional[types.Dtype] = None,
      name: Optional[str] = None,
  ):
      """Initializes a batch of fixed cashflow streams.
  
      Args:
        coupon_spec: An instance of `FixedCouponSpecs` specifying the
          details of the coupon payment for the cashflow stream.
        discount_curve_type: An instance of `CurveType` or a list of those.
          If supplied as a list and `discount_curve_mask` is not supplied,
          the size of the list should be the same as the number of priced
          instruments. Defines discount curves for the instruments.
        start_date: A `DateTensor` of `batch_shape` specifying the starting dates
          of the accrual of the first coupon of the cashflow stream. The shape of
          the input correspond to the number of streams being created.
          When passed as an integet `Tensor`, should be of shape
          `batch_shape + [3]` and contain `[year, month, day]` for each date.
          Either this of `schedule` should be supplied
          Default value: `None`
        end_date: A `DateTensor` of `batch_shape`specifying the end dates for
          accrual of the last coupon in each cashflow stream. The shape of the
          input should be the same as that of `start_date`.
          Either this of `schedule` should be supplied
          When passed as an integet `Tensor`, should be of shape
          `batch_shape + [3]` and contain `[year, month, day]` for each date.
          Default value: `None`
        discount_curve_mask: An optional integer `Tensor` of values ranging from
          `0` to `len(discount_curve_type) - 1` and of shape `batch_shape`.
          Identifies a mapping between `discount_curve_type` list and the
          underlying instruments.
          Default value: `None`.
        first_coupon_date: An optional `DateTensor` specifying the payment dates
          of the first coupon of the cashflow stream. Use this input for cashflows
          with irregular first coupon. Should be of the same shape as
          `start_date`.
          When passed as an integet `Tensor`, should be of shape
          `batch_shape + [3]` and contain `[year, month, day]` for each date.
          Default value: None which implies regular first coupon.
        penultimate_coupon_date: An optional `DateTensor` specifying the payment
          dates of the penultimate (next to last) coupon of the cashflow
          stream. Use this input for cashflows with irregular last coupon.
          Should be of the same shape as `end_date`.
          When passed as an integet `Tensor`, should be of shape
          `batch_shape + [3]` and contain `[year, month, day]` for each date.
          Default value: None which implies regular last coupon.
        schedule_fn: A callable that accepts `start_date`, `end_date`,
          `coupon_frequency`, `settlement_days`, `first_coupon_date`, and
          `penultimate_coupon_date` as `Tensor`s and returns coupon payment
          days.
          Default value: `None`.
        schedule: A `DateTensor` of coupon payment dates including the start and
          end dates of the cashflows.
          Default value: `None`.
        dtype: `tf.Dtype` of the input and output real `Tensor`s.
          Default value: None which maps to the default dtype inferred by
          TensorFlow.
        name: Python str. The name to give to the ops created by this class.
          Default value: `None` which maps to 'fixed_cashflow_stream'.
      """
      self._name = name or "fixed_cashflow_stream"
  
      with tf.name_scope(self._name):
          curve_list = to_list(discount_curve_type)
          [self._discount_curve_type, self._mask] = process_curve_types(
              curve_list, discount_curve_mask
          )
  
          if schedule is None:
              if (start_date is None) or (end_date is None):
                  raise ValueError(
                      "If `schedule` is not supplied both "
                      "`start_date` and `end_date` should be supplied"
                  )
              if isinstance(start_date, tf.Tensor):
                  self._start_date = dateslib.dates_from_tensor(
                      start_date
                  )
              else:
                  self._start_date = dateslib.convert_to_date_tensor(
                      start_date
                  )
              if isinstance(start_date, tf.Tensor):
                  self._end_date = dateslib.dates_from_tensor(end_date)
              else:
                  self._end_date = dateslib.convert_to_date_tensor(
                      end_date
                  )
              self._first_coupon_date = first_coupon_date
              self._penultimate_coupon_date = penultimate_coupon_date
              if self._first_coupon_date is not None:
                  if isinstance(start_date, tf.Tensor):
                      self._first_coupon_date = (
                          dateslib.dates_from_tensor(first_coupon_date)
                      )
                  else:
                      self._first_coupon_date = (
                          dateslib.convert_to_date_tensor(
                              first_coupon_date
                          )
                      )
              if self._penultimate_coupon_date is not None:
                  if isinstance(start_date, tf.Tensor):
                      self._penultimate_coupon_date = (
                          dateslib.dates_from_tensor(
                              penultimate_coupon_date
                          )
                      )
                  else:
                      self._penultimate_coupon_date = (
                          dateslib.convert_to_date_tensor(
                              penultimate_coupon_date
                          )
                      )
  
          # Update coupon frequency
          coupon_frequency = _get_attr(coupon_spec, "coupon_frequency")
          if isinstance(coupon_frequency, period_pb2.Period):
              coupon_frequency = market_data_utils.get_period(
                  _get_attr(coupon_spec, "coupon_frequency")
              )
          if isinstance(coupon_frequency, (list, tuple)):
              coupon_frequency = market_data_utils.period_from_list(
                  *_get_attr(coupon_spec, "coupon_frequency")
              )
          if isinstance(coupon_frequency, dict):
              coupon_frequency = market_data_utils.period_from_dict(
                  _get_attr(coupon_spec, "coupon_frequency")
              )
  
          businessday_rule = coupon_spec.businessday_rule
          # Business day roll convention and the end of month flag
          (
              roll_convention,
              eom,
          ) = market_data_utils.get_business_day_convention(
              businessday_rule
          )
  
          notional = tf.convert_to_tensor(
              _get_attr(coupon_spec, "notional_amount"),
              dtype=dtype,
              name="notional",
          )
          self._dtype = dtype or notional.dtype
          fixed_rate = tf.convert_to_tensor(
              _get_attr(coupon_spec, "fixed_rate"),
              dtype=self._dtype,
              name="fixed_rate",
          )
  
          daycount_fn = market_data_utils.get_daycount_fn(
              _get_attr(coupon_spec, "daycount_convention"), self._dtype
          )
  
          self._settlement_days = tf.convert_to_tensor(
              _get_attr(coupon_spec, "settlement_days"),
              dtype=tf.int32,
              name="settlement_days",
          )
  
          if schedule is not None:
              if isinstance(schedule, tf.Tensor):
                  coupon_dates = dateslib.dates_from_tensor(schedule)
              else:
                  coupon_dates = dateslib.convert_to_date_tensor(
                      schedule
                  )
              # Extract starting date for the cashflow
              self._start_date = coupon_dates[..., 0]
          elif schedule_fn is None:
              # TODO(b/160446193): Calendar is ignored and weekends only is used
              calendar = dateslib.create_holiday_calendar(
                  weekend_mask=dateslib.WeekendMask.SATURDAY_SUNDAY
              )
              self._calendar = calendar
              coupon_dates = _generate_schedule(
                  start_date=self._start_date,
                  end_date=self._end_date,
                  coupon_frequency=coupon_frequency,
                  roll_convention=roll_convention,
                  calendar=calendar,
                  settlement_days=self._settlement_days,
                  end_of_month=eom,
                  first_coupon_date=self._first_coupon_date,
                  penultimate_coupon_date=self._penultimate_coupon_date,
              )
              # Extract starting date for the cashflow
              self._start_date = coupon_dates[..., 0]
          else:
              if first_coupon_date is not None:
                  first_coupon_date = (
                      self._first_coupon_date.to_tensor()
                  )
              if penultimate_coupon_date is not None:
                  penultimate_coupon_date = (
                      self._penultimate_coupon_date.to_tensor()
                  )
                  coupon_dates = schedule_fn(
                      start_date=self._start_date.to_tensor(),
                      end_date=self._end_date.to_tensor(),
                      coupon_frequency=coupon_frequency.quantity(),
                      settlement_days=self._settlement_days,
                      first_coupon_date=first_coupon_date,
                      penultimate_coupon_date=penultimate_coupon_date,
                  )
          # Convert to DateTensor if the result comes from a tf.function
          coupon_dates = dateslib.convert_to_date_tensor(coupon_dates)
  
          self._batch_shape = tf.shape(coupon_dates.ordinal())[:-1]
          payment_dates = coupon_dates[..., 1:]
  
          daycount_fractions = daycount_fn(
              start_date=coupon_dates[..., :-1],
              end_date=coupon_dates[..., 1:],
          )
  
          coupon_rate = tf.expand_dims(fixed_rate, axis=-1)
  
          self._num_cashflows = tf.shape(payment_dates.ordinal())[-1]
          self._payment_dates = payment_dates
          self._notional = notional
          self._daycount_fractions = daycount_fractions
          self._coupon_rate = coupon_rate
          self._fixed_rate = tf.convert_to_tensor(
              fixed_rate, dtype=self._dtype
          )
          self._daycount_fn = daycount_fn
  
imports: from typing import Optional, Tuple, Callable, Any, List, Union
  import numpy
  import tensorflow.compat.v2
  from tf_quant_finance import datetime
  from tf_quant_finance.experimental.pricing_platform.framework.core import curve_types
  from tf_quant_finance.experimental.pricing_platform.framework.core import processed_market_data
  from tf_quant_finance.experimental.pricing_platform.framework.core import types
  from tf_quant_finance.experimental.pricing_platform.framework.market_data import rate_curve
  from tf_quant_finance.experimental.pricing_platform.framework.market_data import utils
  from tf_quant_finance.experimental.pricing_platform.framework.rate_instruments import coupon_specs
  from tf_quant_finance.experimental.pricing_platform.instrument_protos import period_pb2
  from tf_quant_finance.math import pad
label_desc: Use image node_id 1 to create a new FixedCashflowStream object  with example: obj = FixedCashflowStream(coupon_spec, discount_curve_type, start_date, end_date, discount_curve_mask, first_coupon_date, penultimate_coupon_date, schedule_fn, schedule, dtype, name)