class_docstr: Calculate affinities using a Gaussian mixture kernel.
  
  Instead of using a single perplexity to compute the affinities between data
  points, we can use a multiscale Gaussian kernel instead. This allows us to
  incorporate long range interactions.
  
  Please see the :ref:`parameter-guide` for more information.
  
  Parameters
  ----------
  data: np.ndarray
      The data matrix.
  
  perplexities: List[float]
      A list of perplexity values, which will be used in the multiscale
      Gaussian kernel. Perplexity can be thought of as the continuous
      :math:`k` number of nearest neighbors, for which t-SNE will attempt to
      preserve distances.
  
  method: str
      Specifies the nearest neighbor method to use. Can be ``exact``, ``annoy``,
      ``pynndescent``, ``hnsw``, ``approx``, or ``auto`` (default). ``approx``
      uses Annoy if the input data matrix is not a sparse object and if Annoy
      supports the given metric. Otherwise, it uses Pynndescent. ``auto`` uses
      exact nearest neighbors for N<1000 and the same heuristic as ``approx``
      for N>=1000.
  
  metric: Union[str, Callable]
      The metric to be used to compute affinities between points in the
      original space.
  
  metric_params: dict
      Additional keyword arguments for the metric function.
  
  symmetrize: bool
      Symmetrize the affinity matrix. During standard t-SNE optimization, the
      affinities are symmetrized. However, when embedding new data points into
      existing embeddings, symmetrization is not performed.
  
  n_jobs: int
      The number of threads to use while running t-SNE. This follows the
      scikit-learn convention, ``-1`` meaning all processors, ``-2`` meaning
      all but one, etc.
  
  random_state: Union[int, RandomState]
      If the value is an int, random_state is the seed used by the random
      number generator. If the value is a RandomState instance, then it will
      be used as the random number generator. If the value is None, the random
      number generator is the RandomState instance used by `np.random`.
  
  verbose: bool
  
  knn_index: Optional[nearest_neighbors.KNNIndex]
      Optionally, a precomptued ``openTSNE.nearest_neighbors.KNNIndex`` object
      can be specified. This option will ignore any KNN-related parameters.
      When ``knn_index`` is specified, ``data`` must be set to None.
class_docstr_tok: ["Calculate","affinities","using","a","Gaussian","mixture","kernel",".","Instead","of","using","a","single","perplexity","to","compute","the","affinities","between","data","points",",","we","can","use","a","multiscale","Gaussian","kernel","instead",".","This","allows","us","to","incorporate","long","range","interactions",".","Please","see","the",":","ref",":","`","parameter-guide","`","for","more","information",".","Parameters","--","--","--","--","--","data",":","np.ndarray","The","data","matrix",".","perplexities",":","List","[","float","]","A","list","of","perplexity","values",",","which","will","be","used","in","the","multiscale","Gaussian","kernel",".","Perplexity","can","be","thought","of","as","the","continuous",":","math",":","`","k","`","number","of","nearest","neighbors",",","for","which","t-SNE","will","attempt","to","preserve","distances",".","method",":","str","Specifies","the","nearest","neighbor","method","to","use",".","Can","be","``","exact","``",",","``","annoy","``",",","``","pynndescent","``",",","``","hnsw","``",",","``","approx","``",",","or","``","auto","``","(","default",")",".","``","approx","``","uses","Annoy","if","the","input","data","matrix","is","not","a","sparse","object","and","if","Annoy","supports","the","given","metric",".","Otherwise",",","it","uses","Pynndescent",".","``","auto","``","uses","exact","nearest","neighbors","for","N","<","1000","and","the","same","heuristic","as","``","approx","``","for","N",">","=1000",".","metric",":","Union","[","str",",","Callable","]","The","metric","to","be","used","to","compute","affinities","between","points","in","the","original","space",".","metric_params",":","dict","Additional","keyword","arguments","for","the","metric","function",".","symmetrize",":","bool","Symmetrize","the","affinity","matrix",".","During","standard","t-SNE","optimization",",","the","affinities","are","symmetrized",".","However",",","when","embedding","new","data","points","into","existing","embeddings",",","symmetrization","is","not","performed",".","n_jobs",":","int","The","number","of","threads","to","use","while","running","t-SNE",".","This","follows","the","scikit-learn","convention",",","``","-1","``","meaning","all","processors",",","``","-2","``","meaning","all","but","one",",","etc",".","random_state",":","Union","[","int",",","RandomState","]","If","the","value","is","an","int",",","random_state","is","the","seed","used","by","the","random","number","generator",".","If","the","value","is","a","RandomState","instance",",","then","it","will","be","used","as","the","random","number","generator",".","If","the","value","is","None",",","the","random","number","generator","is","the","RandomState","instance","used","by","`","np.random","`",".","verbose",":","bool","knn_index",":","Optional","[","nearest_neighbors.KNNIndex","]","Optionally",",","a","precomptued","``","openTSNE.nearest_neighbors.KNNIndex","``","object","can","be","specified",".","This","option","will","ignore","any","KNN-related","parameters",".","When","``","knn_index","``","is","specified",",","``","data","``","must","be","set","to","None","."]
code: def __init__(
      self,
      data=None,
      perplexities=None,
      method="auto",
      metric="euclidean",
      metric_params=None,
      symmetrize=True,
      n_jobs=1,
      random_state=None,
      verbose=False,
      knn_index=None,
  ):
      # Perplexities must be specified, but has default set to none, so the
      # parameter order makes more sense
      if perplexities is None:
          raise ValueError("`perplexities` must be specified!")
  
      # This can't work if neither data nor the knn index are specified
      if data is None and knn_index is None:
          raise ValueError(
              "At least one of the parameters `data` or `knn_index` must be specified!"
          )
      # This can't work if both data and the knn index are specified
      if data is not None and knn_index is not None:
          raise ValueError(
              "Both `data` or `knn_index` were specified! Please pass only one."
          )
  
      # Find the nearest neighbors
      if knn_index is None:
          # We will compute the nearest neighbors to the max value of perplexity,
          # smaller values can just use indexing to truncate unneeded neighbors
          n_samples = data.shape[0]
          effective_perplexities = self.check_perplexities(
              perplexities, n_samples
          )
          max_perplexity = np.max(effective_perplexities)
          k_neighbors = min(n_samples - 1, int(3 * max_perplexity))
  
          self.knn_index = get_knn_index(
              data,
              method,
              k_neighbors,
              metric,
              metric_params,
              n_jobs,
              random_state,
              verbose,
          )
  
      else:
          self.knn_index = knn_index
          n_samples = self.knn_index.n_samples
          effective_perplexities = self.check_perplexities(
              perplexities, n_samples
          )
          log.info(
              "KNN index provided. Ignoring KNN-related parameters."
          )
  
      self.__neighbors, self.__distances = self.knn_index.build()
  
      with utils.Timer("Calculating affinity matrix...", verbose):
          self.P = self._calculate_P(
              self.__neighbors,
              self.__distances,
              effective_perplexities,
              symmetrize=symmetrize,
              n_jobs=n_jobs,
          )
  
      self.perplexities = perplexities
      self.effective_perplexities_ = effective_perplexities
      self.symmetrize = symmetrize
      self.n_jobs = n_jobs
      self.verbose = verbose
  
imports: import logging
  import numbers
  import operator
  from functools import reduce
  import numpy
  import scipy.sparse
  from openTSNE import _tsne
  from openTSNE import nearest_neighbors
  from openTSNE import utils
  from openTSNE.utils import is_package_installed
  import warnings
label_desc: Use image node_id 1 to create a new MultiscaleMixture object from inherited base classes: Affinities with example: obj = MultiscaleMixture(data, perplexities, method, metric, metric_params, symmetrize, n_jobs, random_state, verbose, knn_index)