class_docstr: Sparse Random Projection using Paddle operations.
  
  Args:
      eps (float, optional): Minimum distortion rate parameter for calculating
          Johnson-Lindenstrauss minimum dimensions. Defaults to 0.1.
      random_state (Optional[int], optional): Uses the seed to set the random
          state for sample_without_replacement function. Defaults to None.
class_docstr_tok: ["Sparse","Random","Projection","using","Paddle","operations",".","Args",":","eps","(","float",",","optional",")",":","Minimum","distortion","rate","parameter","for","calculating","Johnson-Lindenstrauss","minimum","dimensions",".","Defaults","to","0.1.","random_state","(","Optional","[","int","]",",","optional",")",":","Uses","the","seed","to","set","the","random","state","for","sample_without_replacement","function",".","Defaults","to","None","."]
docstr: Random sparse matrix. Based on https://web.stanford.edu/~hastie/Papers/Ping/KDD06_rp.pdf.
  
  # paddle can't multiply directly on sparse matrix and moving sparse matrix to cuda throws error
  # (Could not run 'aten::empty_strided' with arguments from the 'SparseCsrCUDA' backend)
  # hence sparse matrix is stored as a dense matrix
  
  Args:
      n_components (int): Dimensionality of the target projection space.
      n_features (int): Dimentionality of the original source space.
  
  Returns:
      Tensor: Sparse matrix of shape (n_components, n_features).
          The generated Gaussian random matrix is in CSR (compressed sparse row)
          format.
docstr_tok: ["Random","sparse","matrix",".","Based","on","https",":","\/\/web.stanford.edu\/~hastie\/Papers\/Ping\/KDD06_rp.pdf",".","#","paddle","ca","n't","multiply","directly","on","sparse","matrix","and","moving","sparse","matrix","to","cuda","throws","error","#","(","Could","not","run","'aten",":",":empty_strided","'","with","arguments","from","the","'SparseCsrCUDA","'","backend",")","#","hence","sparse","matrix","is","stored","as","a","dense","matrix","Args",":","n_components","(","int",")",":","Dimensionality","of","the","target","projection","space",".","n_features","(","int",")",":","Dimentionality","of","the","original","source","space",".","Returns",":","Tensor",":","Sparse","matrix","of","shape","(","n_components",",","n_features",")",".","The","generated","Gaussian","random","matrix","is","in","CSR","(","compressed","sparse","row",")","format","."]
code: def _make_random_matrix(self, n_components: int, n_features: int):
      """Random sparse matrix. Based on https://web.stanford.edu/~hastie/Papers/Ping/KDD06_rp.pdf.
  
      # paddle can't multiply directly on sparse matrix and moving sparse matrix to cuda throws error
      # (Could not run 'aten::empty_strided' with arguments from the 'SparseCsrCUDA' backend)
      # hence sparse matrix is stored as a dense matrix
  
      Args:
          n_components (int): Dimensionality of the target projection space.
          n_features (int): Dimentionality of the original source space.
  
      Returns:
          Tensor: Sparse matrix of shape (n_components, n_features).
              The generated Gaussian random matrix is in CSR (compressed sparse row)
              format.
      """
  
      # Density 'auto'. Factorize density
      density = 1 / np.sqrt(n_features)
  
      if density == 1:
          # skip index generation if totally dense
          binomial = paddle.distributions.Binomial(
              total_count=1, probs=0.5
          )
          components = (
              binomial.sample((n_components, n_features)) * 2 - 1
          )
          components = 1 / np.sqrt(n_components) * components
  
      else:
          # Sparse matrix is not being generated here as it is stored as dense anyways
          components = paddle.zeros(
              (n_components, n_features), dtype=paddle.float64
          )
          for i in range(n_components):
              # find the indices of the non-zero components for row i
              nnz_idx = np.random.binomial(n_features, density)
              # get nnz_idx column indices
              # pylint: disable=not-callable
              c_idx = paddle.to_tensor(
                  sample_without_replacement(
                      n_population=n_features,
                      n_samples=nnz_idx,
                      random_state=self.random_state,
                  ),
                  dtype="int64",
              )
              data = (
                  paddle.to_tensor(
                      np.random.binomial(1, 0.5, c_idx.size)
                  )
                  * 2
                  - 1
              )
              # assign data to only those columns
              components[i, c_idx] = data
  
          components *= np.sqrt(1 / density) / np.sqrt(n_components)
  
      return components.astype("float32")
  
imports: import warnings
  from typing import Optional
  import paddle
  from paddle import Tensor
  import numpy
  from sklearn.utils.random import sample_without_replacement
label_desc: Use image node_id 1 for calling the SparseRandomProjection obj's underlying member method code with example usage: obj._make_random_matrix(n_components, n_features) and returns: components