class_docstr: A selector based off a feature based submodular function.
  
  Feature-based functions are those that operate on the feature values of 
  examples directly, rather than on a similarity matrix (or graph) derived 
  from those features, as graph-based functions do. Because these functions 
  do not require calculating and storing a :math:`\mathcal{O}(n^{2})` sized 
  matrix of similarities, they can easily scale to data sets with millions of 
  examples. 
  
  .. note:: 
          All values in your data must be positive for this selection to work.
  
  The general form of a feature-based function is:
  
  .. math::
          f(X) = \sum\limits_{d=1}^{D}\phi\left(\sum\limits_{i=1}^{N} X_{i, d}\right)
  
  where :math:`f` indicates the function that uses the concave function 
  :math:`\phi` and is operating on a subset :math:`X` that has :math:`N` 
  examples and :math:`D` dimensions. Importantly, :math:`X` is the subset 
  and not the ground set, meaning that the time it takes to evaluate this 
  function is proportional only to the size of the selected subset and not 
  the size of the full data set, like it is for graph-based functions.  
  
  See https://ieeexplore.ieee.org/document/6854213 for more details on
  feature based functions.
  
  Parameters
  ----------
  n_samples : int
          The number of samples to return.
  
  concave_func : str or callable
          The type of concave function to apply to the feature values. You can
          pass in your own function to apply. Otherwise must be one of the
          following:
  
                  'log' : log(1 + X)
                  'sqrt' : sqrt(X)
                  'sigmoid' : X / (1 + X)
  
  initial_subset : list, numpy.ndarray or None
          If provided, this should be a list of indices into the data matrix
          to use as the initial subset, or a group of examples that may not be
          in the provided data should beused as the initial subset. If indices, 
          the provided array should be one-dimensional. If a group of examples,
          the data should be 2 dimensional.
  
  optimizer : string or optimizers.BaseOptimizer, optional
          The optimization approach to use for the selection. Default is
          'two-stage', which makes selections using the naive greedy algorithm
          initially and then switches to the lazy greedy algorithm. Must be
          one of
  
                  'random' : randomly select elements (dummy optimizer)
                  'modular' : approximate the function using its modular upper bound
                  'naive' : the naive greedy algorithm
                  'lazy' : the lazy (or accelerated) greedy algorithm
                  'approximate-lazy' : the approximate lazy greedy algorithm
                  'two-stage' : starts with naive and switches to lazy
                  'stochastic' : the stochastic greedy algorithm
                  'sample' : randomly take a subset and perform selection on that
                  'greedi' : the GreeDi distributed algorithm
                  'bidirectional' : the bidirectional greedy algorithm
  
          Default is 'two-stage'.
  
  optimizer_kwds : dict or None
          A dictionary of arguments to pass into the optimizer object. The keys
          of this dictionary should be the names of the parameters in the optimizer
          and the values in the dictionary should be the values that these
          parameters take. Default is None.
  
  reservoir : numpy.ndarray or None
          The reservoir to use when calculating gains in the sieve greedy
          streaming optimization algorithm in the `partial_fit` method.
          Currently only used for graph-based functions. If a numpy array
          is passed in, it will be used as the reservoir. If None is passed in,
          will use reservoir sampling to collect a reservoir. Default is None.
  
  max_reservoir_size : int 
          The maximum size that the reservoir can take. If a reservoir is passed
          in, this value is set to the size of that array. Default is 1000.
  
  n_jobs : int
          The number of threads to use when performing computation in parallel.
          Currently, this parameter is exposed but does not actually do anything.
          This will be fixed soon.
  
  random_state : int or RandomState or None, optional
          The random seed to use for the random selection process. Only used
          for stochastic greedy.
  
  verbose : bool
          Whether to print output during the selection process.
  
  Attributes
  ----------
  n_samples : int
          The number of samples to select.
  
  ranking : numpy.array int
          The selected samples in the order of their gain with the first number in
          the ranking corresponding to the index of the first sample that was
          selected by the greedy procedure.
  
  gains : numpy.array float
          The gain of each sample in the returned set when it was added to the
          growing subset. The first number corresponds to the gain of the first
          added sample, the second corresponds to the gain of the second added
          sample, and so forth.
class_docstr_tok: ["A","selector","based","off","a","feature","based","submodular","function",".","Feature-based","functions","are","those","that","operate","on","the","feature","values","of","examples","directly",",","rather","than","on","a","similarity","matrix","(","or","graph",")","derived","from","those","features",",","as","graph-based","functions","do",".","Because","these","functions","do","not","require","calculating","and","storing","a",":","math",":","`","\\mathcal","{","O","}","(","n^","{","2","}",")","`","sized","matrix","of","similarities",",","they","can","easily","scale","to","data","sets","with","millions","of","examples",".","..","note",":",":","All","values","in","your","data","must","be","positive","for","this","selection","to","work",".","The","general","form","of","a","feature-based","function","is",":","..","math",":",":","f","(","X",")","=","\\sum\\limits_","{","d=1","}","^","{","D","}","\\phi\\left","(","\\sum\\limits_","{","i=1","}","^","{","N","}","X_","{","i",",","d","}","\\right",")","where",":","math",":","`","f","`","indicates","the","function","that","uses","the","concave","function",":","math",":","`","\\phi","`","and","is","operating","on","a","subset",":","math",":","`","X","`","that","has",":","math",":","`","N","`","examples","and",":","math",":","`","D","`","dimensions",".","Importantly",",",":","math",":","`","X","`","is","the","subset","and","not","the","ground","set",",","meaning","that","the","time","it","takes","to","evaluate","this","function","is","proportional","only","to","the","size","of","the","selected","subset","and","not","the","size","of","the","full","data","set",",","like","it","is","for","graph-based","functions",".","See","https",":","\/\/ieeexplore.ieee.org\/document\/6854213","for","more","details","on","feature","based","functions",".","Parameters","--","--","--","--","--","n_samples",":","int","The","number","of","samples","to","return",".","concave_func",":","str","or","callable","The","type","of","concave","function","to","apply","to","the","feature","values",".","You","can","pass","in","your","own","function","to","apply",".","Otherwise","must","be","one","of","the","following",":","'log","'",":","log","(","1","+","X",")","'sqrt","'",":","sqrt","(","X",")","'sigmoid","'",":","X","\/","(","1","+","X",")","initial_subset",":","list",",","numpy.ndarray","or","None","If","provided",",","this","should","be","a","list","of","indices","into","the","data","matrix","to","use","as","the","initial","subset",",","or","a","group","of","examples","that","may","not","be","in","the","provided","data","should","beused","as","the","initial","subset",".","If","indices",",","the","provided","array","should","be","one-dimensional",".","If","a","group","of","examples",",","the","data","should","be","2","dimensional",".","optimizer",":","string","or","optimizers.BaseOptimizer",",","optional","The","optimization","approach","to","use","for","the","selection",".","Default","is","'two-stage","'",",","which","makes","selections","using","the","naive","greedy","algorithm","initially","and","then","switches","to","the","lazy","greedy","algorithm",".","Must","be","one","of","'random","'",":","randomly","select","elements","(","dummy","optimizer",")","'modular","'",":","approximate","the","function","using","its","modular","upper","bound","'naive","'",":","the","naive","greedy","algorithm","'lazy","'",":","the","lazy","(","or","accelerated",")","greedy","algorithm","'approximate-lazy","'",":","the","approximate","lazy","greedy","algorithm","'two-stage","'",":","starts","with","naive","and","switches","to","lazy","'stochastic","'",":","the","stochastic","greedy","algorithm","'sample","'",":","randomly","take","a","subset","and","perform","selection","on","that","'greedi","'",":","the","GreeDi","distributed","algorithm","'bidirectional","'",":","the","bidirectional","greedy","algorithm","Default","is","'two-stage","'",".","optimizer_kwds",":","dict","or","None","A","dictionary","of","arguments","to","pass","into","the","optimizer","object",".","The","keys","of","this","dictionary","should","be","the","names","of","the","parameters","in","the","optimizer","and","the","values","in","the","dictionary","should","be","the","values","that","these","parameters","take",".","Default","is","None",".","reservoir",":","numpy.ndarray","or","None","The","reservoir","to","use","when","calculating","gains","in","the","sieve","greedy","streaming","optimization","algorithm","in","the","`","partial_fit","`","method",".","Currently","only","used","for","graph-based","functions",".","If","a","numpy","array","is","passed","in",",","it","will","be","used","as","the","reservoir",".","If","None","is","passed","in",",","will","use","reservoir","sampling","to","collect","a","reservoir",".","Default","is","None",".","max_reservoir_size",":","int","The","maximum","size","that","the","reservoir","can","take",".","If","a","reservoir","is","passed","in",",","this","value","is","set","to","the","size","of","that","array",".","Default","is","1000.","n_jobs",":","int","The","number","of","threads","to","use","when","performing","computation","in","parallel",".","Currently",",","this","parameter","is","exposed","but","does","not","actually","do","anything",".","This","will","be","fixed","soon",".","random_state",":","int","or","RandomState","or","None",",","optional","The","random","seed","to","use","for","the","random","selection","process",".","Only","used","for","stochastic","greedy",".","verbose",":","bool","Whether","to","print","output","during","the","selection","process",".","Attributes","--","--","--","--","--","n_samples",":","int","The","number","of","samples","to","select",".","ranking",":","numpy.array","int","The","selected","samples","in","the","order","of","their","gain","with","the","first","number","in","the","ranking","corresponding","to","the","index","of","the","first","sample","that","was","selected","by","the","greedy","procedure",".","gains",":","numpy.array","float","The","gain","of","each","sample","in","the","returned","set","when","it","was","added","to","the","growing","subset",".","The","first","number","corresponds","to","the","gain","of","the","first","added","sample",",","the","second","corresponds","to","the","gain","of","the","second","added","sample",",","and","so","forth","."]
code: def _initialize(self, X):
      super(FeatureBasedSelection, self)._initialize(X)
  
      if self.initial_subset is None:
          pass
      elif self.initial_subset.ndim == 2:
          self.current_values = self.initial_subset.sum(axis=0).astype(
              "float64"
          )
      elif self.initial_subset.ndim == 1:
          self.current_values = (
              X[self.initial_subset].sum(axis=0).astype("float64")
          )
      else:
          raise ValueError(
              "The initial subset must be either a two dimensional"
              " matrix of examples or a one dimensional mask."
          )
  
      self.current_concave_values = self.concave_func(
          self.current_values
      )
      self.current_concave_values_sum = (
          self.current_concave_values.sum()
      )
  
      calculate_gains_ = (
          calculate_gains_sparse if self.sparse else calculate_gains
      )
      dtypes_ = sparse_dtypes if self.sparse else dtypes
  
      if self.optimizer in (
          LazyGreedy,
          ApproximateLazyGreedy,
          "lazy",
          "approximate-lazy",
      ):
          self.calculate_gains_ = calculate_gains_(
              self.concave_func, dtypes_, False, True, False
          )
      else:
          self.calculate_gains_ = calculate_gains_(
              self.concave_func, dtypes_, True, True, False
          )
  
      calculate_sieve_gains_ = (
          calculate_gains_sieve_sparse
          if self.sparse
          else calculate_gains_sieve
      )
      dtypes_ = sieve_sparse_dtypes if self.sparse else sieve_dtypes
      self.calculate_sieve_gains_ = calculate_sieve_gains_(
          self.concave_func, dtypes_, True, True, False
      )
  
imports: import math
  import numpy
  from .base import BaseSelection
  from ..optimizers import LazyGreedy
  from ..optimizers import ApproximateLazyGreedy
  from tqdm import tqdm
  from numba import njit
  from numba import prange
  import torch
label_desc: Use image node_id 3 for calling the FeatureBasedSelection obj's underlying member method code with example usage: obj._initialize(X) without return types