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","."]
docstr: Compute the affinities of new samples to the initial samples.
  
  This is necessary for embedding new data points into an existing
  embedding.
  
  Please see the :ref:`parameter-guide` for more information.
  
  Parameters
  ----------
  data: np.ndarray
      The data points to be added to the existing embedding.
  
  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.
  
  return_distances: bool
      If needed, the function can return the indices of the nearest
      neighbors and their corresponding distances.
  
  Returns
  -------
  P: array_like
      An :math:`N \times M` affinity matrix expressing interactions
      between :math:`N` new data points the initial :math:`M` data
      samples.
  
  indices: np.ndarray
      Returned if ``return_distances=True``. The indices of the :math:`k`
      nearest neighbors in the existing embedding for every new data
      point.
  
  distances: np.ndarray
      Returned if ``return_distances=True``. The distances to the
      :math:`k` nearest neighbors in the existing embedding for every new
      data point.
docstr_tok: ["Compute","the","affinities","of","new","samples","to","the","initial","samples",".","This","is","necessary","for","embedding","new","data","points","into","an","existing","embedding",".","Please","see","the",":","ref",":","`","parameter-guide","`","for","more","information",".","Parameters","--","--","--","--","--","data",":","np.ndarray","The","data","points","to","be","added","to","the","existing","embedding",".","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",".","return_distances",":","bool","If","needed",",","the","function","can","return","the","indices","of","the","nearest","neighbors","and","their","corresponding","distances",".","Returns","--","--","--","-","P",":","array_like","An",":","math",":","`","N","\\times","M","`","affinity","matrix","expressing","interactions","between",":","math",":","`","N","`","new","data","points","the","initial",":","math",":","`","M","`","data","samples",".","indices",":","np.ndarray","Returned","if","``","return_distances=True","``",".","The","indices","of","the",":","math",":","`","k","`","nearest","neighbors","in","the","existing","embedding","for","every","new","data","point",".","distances",":","np.ndarray","Returned","if","``","return_distances=True","``",".","The","distances","to","the",":","math",":","`","k","`","nearest","neighbors","in","the","existing","embedding","for","every","new","data","point","."]
code: def to_new(self, data, perplexities=None, return_distances=False):
      """Compute the affinities of new samples to the initial samples.
  
      This is necessary for embedding new data points into an existing
      embedding.
  
      Please see the :ref:`parameter-guide` for more information.
  
      Parameters
      ----------
      data: np.ndarray
          The data points to be added to the existing embedding.
  
      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.
  
      return_distances: bool
          If needed, the function can return the indices of the nearest
          neighbors and their corresponding distances.
  
      Returns
      -------
      P: array_like
          An :math:`N \\times M` affinity matrix expressing interactions
          between :math:`N` new data points the initial :math:`M` data
          samples.
  
      indices: np.ndarray
          Returned if ``return_distances=True``. The indices of the :math:`k`
          nearest neighbors in the existing embedding for every new data
          point.
  
      distances: np.ndarray
          Returned if ``return_distances=True``. The distances to the
          :math:`k` nearest neighbors in the existing embedding for every new
          data point.
  
      """
      perplexities = (
          perplexities
          if perplexities is not None
          else self.perplexities
      )
      effective_perplexities = self.check_perplexities(
          perplexities, self.n_samples
      )
  
      max_perplexity = np.max(effective_perplexities)
      k_neighbors = min(self.n_samples - 1, int(3 * max_perplexity))
  
      neighbors, distances = self.knn_index.query(data, k_neighbors)
  
      with utils.Timer("Calculating affinity matrix...", self.verbose):
          P = self._calculate_P(
              neighbors,
              distances,
              effective_perplexities,
              symmetrize=False,
              normalization="point-wise",
              n_reference_samples=self.n_samples,
              n_jobs=self.n_jobs,
          )
  
      if return_distances:
          return P, neighbors, distances
  
      return P
  
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 4 for calling the MultiscaleMixture obj's underlying member method code with example usage: obj.to_new(data, perplexities, return_distances) and returns: P, P,  neighbors,  distances