class_docstr: Transforms longitudinal exposure features to add the corresponding
  product features.
  
  This preprocessor transform an input list of `n_cases` numpy arrays or
  csr_matrices of shape `(n_intervals, n_features)` so as to add columns
  representing the product of combination of two features. It outputs a list
  of `n_cases` numpy arrays or  csr_matrices of shape `(n_intervals,
  n_features + comb(n_features, 2))`.
  
  Exposure can take two forms:
  - short repeated exposures: in that case, each column of the numpy arrays
  or csr matrices can contain multiple ones, each one representing an exposure
  for a particular time bucket.
  - infinite unique exposures: in that case, each column of the numpy arrays
  or csr matrices can only contain a single one, corresponding to the starting
  date of the exposure.
  
  Parameters
  ----------
  exposure_type : {'infinite', 'short'}, default='infinite'
      Either 'infinite' for infinite unique exposures or 'short' for short
      repeated exposures.
  
  n_jobs : `int`, default=-1
      Number of tasks to run in parallel. If set to -1, the number of tasks is
      set to the number of cores.
  
  Attributes
  ----------
  mapper : `dict`
      Map product features to column indexes of the resulting matrices.
  
  Examples
  --------
  >>> from pprint import pprint
  >>> from scipy.sparse import csr_matrix
  >>> from tick.preprocessing.longitudinal_features_product import LongitudinalFeaturesProduct
  >>> infinite_exposures = [csr_matrix([[0, 1, 0],
  ...                                   [0, 0, 0],
  ...                                   [0, 0, 1]], dtype="float64"),
  ...                       csr_matrix([[1, 1, 0],
  ...                                   [0, 0, 1],
  ...                                   [0, 0, 0]], dtype="float64")
  ...                       ]
  >>> lfp = LongitudinalFeaturesProduct(exposure_type="infinite")
  >>> product_features, _, _ = lfp.fit_transform(features)
  >>> # output comes as a list of sparse matrices or 2D numpy arrays
  >>> product_features.__class__
  <class 'list'>
  >>> [x.toarray() for x in product_features]
  [array([[0., 1., 0., 0., 0., 0.],
         [0., 0., 0., 0., 0., 0.],
         [0., 0., 1., 0., 0., 1.]]), array([[1., 1., 0., 1., 0., 0.],
         [0., 0., 1., 0., 1., 1.],
         [0., 0., 0., 0., 0., 0.]])]
class_docstr_tok: ["Transforms","longitudinal","exposure","features","to","add","the","corresponding","product","features",".","This","preprocessor","transform","an","input","list","of","`","n_cases","`","numpy","arrays","or","csr_matrices","of","shape","`","(","n_intervals",",","n_features",")","`","so","as","to","add","columns","representing","the","product","of","combination","of","two","features",".","It","outputs","a","list","of","`","n_cases","`","numpy","arrays","or","csr_matrices","of","shape","`","(","n_intervals",",","n_features","+","comb","(","n_features",",","2",")",")","`",".","Exposure","can","take","two","forms",":","-","short","repeated","exposures",":","in","that","case",",","each","column","of","the","numpy","arrays","or","csr","matrices","can","contain","multiple","ones",",","each","one","representing","an","exposure","for","a","particular","time","bucket",".","-","infinite","unique","exposures",":","in","that","case",",","each","column","of","the","numpy","arrays","or","csr","matrices","can","only","contain","a","single","one",",","corresponding","to","the","starting","date","of","the","exposure",".","Parameters","--","--","--","--","--","exposure_type",":","{","'infinite","'",",","'short","'","}",",","default='infinite'","Either","'infinite","'","for","infinite","unique","exposures","or","'short","'","for","short","repeated","exposures",".","n_jobs",":","`","int","`",",","default=-1","Number","of","tasks","to","run","in","parallel",".","If","set","to","-1",",","the","number","of","tasks","is","set","to","the","number","of","cores",".","Attributes","--","--","--","--","--","mapper",":","`","dict","`","Map","product","features","to","column","indexes","of","the","resulting","matrices",".","Examples","--","--","--","--",">",">",">","from","pprint","import","pprint",">",">",">","from","scipy.sparse","import","csr_matrix",">",">",">","from","tick.preprocessing.longitudinal_features_product","import","LongitudinalFeaturesProduct",">",">",">","infinite_exposures","=","[","csr_matrix","(","[","[","0",",","1",",","0","]",",","...","[","0",",","0",",","0","]",",","...","[","0",",","0",",","1","]","]",",","dtype=","''","float64","''",")",",","...","csr_matrix","(","[","[","1",",","1",",","0","]",",","...","[","0",",","0",",","1","]",",","...","[","0",",","0",",","0","]","]",",","dtype=","''","float64","''",")","...","]",">",">",">","lfp","=","LongitudinalFeaturesProduct","(","exposure_type=","''","infinite","''",")",">",">",">","product_features",",","_",",","_","=","lfp.fit_transform","(","features",")",">",">",">","#","output","comes","as","a","list","of","sparse","matrices","or","2D","numpy","arrays",">",">",">","product_features.__class__","<","class","'list","'",">",">",">",">","[","x.toarray","(",")","for","x","in","product_features","]","[","array","(","[","[","0.",",","1.",",","0.",",","0.",",","0.",",","0",".","]",",","[","0.",",","0.",",","0.",",","0.",",","0.",",","0",".","]",",","[","0.",",","0.",",","1.",",","0.",",","0.",",","1",".","]","]",")",",","array","(","[","[","1.",",","1.",",","0.",",","1.",",","0.",",","0",".","]",",","[","0.",",","0.",",","1.",",","0.",",","1.",",","1",".","]",",","[","0.",",","0.",",","0.",",","0.",",","0.",",","0",".","]","]",")","]"]
docstr: Performs feature product on a scipy.sparse.csr_matrix containing
  infinite exposures.
docstr_tok: ["Performs","feature","product","on","a","scipy.sparse.csr_matrix","containing","infinite","exposures","."]
code: def _sparse_infinite_product(self, feat_mat):
      """Performs feature product on a scipy.sparse.csr_matrix containing
      infinite exposures."""
      coo = feat_mat.tocoo()
      nnz = coo.nnz
      new_nnz = self._n_output_features * nnz
      new_row = np.zeros((new_nnz,), dtype="uint64")
      new_col = np.zeros((new_nnz,), dtype="uint64")
      new_data = np.zeros((new_nnz,), dtype="float64")
      self._preprocessor.sparse_features_product(
          coo.row.astype("uint64"),
          coo.col.astype("uint64"),
          coo.data,
          new_row,
          new_col,
          new_data,
      )
      return sps.csr_matrix(
          (new_data, (new_row, new_col)),
          shape=(self._n_intervals, self._n_output_features),
      )
  
imports: import numpy
  import scipy.sparse
  from itertools import combinations
  from copy import deepcopy
  from scipy.special import comb
  from joblib import Parallel, delayed
  from tick.preprocessing.base import LongitudinalPreprocessor
  from .build.preprocessing import SparseLongitudinalFeaturesProduct
  from .utils import check_longitudinal_features_consistency
label_desc: Use image node_id 10 for calling the LongitudinalFeaturesProduct obj's underlying member method code with example usage: obj._sparse_infinite_product(feat_mat) and returns: sps