code: def joint_probabilities_nn(
      neighbors,
      distances,
      perplexities,
      symmetrize=True,
      normalization="pair-wise",
      n_reference_samples=None,
      n_jobs=1,
  ):
      """Compute the conditional probability matrix P_{j|i}.
  
      This method computes an approximation to P using the nearest neighbors.
  
      Parameters
      ----------
      neighbors: np.ndarray
          A `n_samples * k_neighbors` matrix containing the indices to each
          points' nearest neighbors in descending order.
      distances: np.ndarray
          A `n_samples * k_neighbors` matrix containing the distances to the
          neighbors at indices defined in the neighbors parameter.
      perplexities: double
          The desired perplexity of the probability distribution.
      symmetrize: bool
          Whether to symmetrize the probability matrix or not. Symmetrizing is
          used for typical t-SNE, but does not make sense when embedding new data
          into an existing embedding.
      normalization: str
          The normalization scheme to use for the affinities. Standard t-SNE
          considers interactions between all the data points, therefore the entire
          affinity matrix is regarded as a probability distribution, and must sum
          to 1. When embedding new points, we only consider interactions to
          existing points, and treat each point separately. In this case, we
          row-normalize the affinity matrix, meaning each point gets its own
          probability distribution.
      n_reference_samples: int
          The number of samples in the existing (reference) embedding. Needed to
          properly construct the sparse P matrix.
      n_jobs: int
          Number of threads.
  
      Returns
      -------
      csr_matrix
          A `n_samples * n_reference_samples` matrix containing the probabilities
          that a new sample would appear as a neighbor of a reference point.
  
      """
      assert normalization in (
          "pair-wise",
          "point-wise",
      ), f"Unrecognized normalization scheme `{normalization}`."
  
      n_samples, k_neighbors = distances.shape
  
      if n_reference_samples is None:
          n_reference_samples = n_samples
  
      # Compute asymmetric pairwise input similarities
      conditional_P = _tsne.compute_gaussian_perplexity(
          np.array(distances, dtype=float),
          np.array(perplexities, dtype=float),
          num_threads=n_jobs,
      )
      conditional_P = np.asarray(conditional_P)
  
      P = sp.csr_matrix(
          (
              conditional_P.ravel(),
              neighbors.ravel(),
              range(0, n_samples * k_neighbors + 1, k_neighbors),
          ),
          shape=(n_samples, n_reference_samples),
      )
  
      # Symmetrize the probability matrix
      if symmetrize:
          P = (P + P.T) / 2
  
      if normalization == "pair-wise":
          P /= np.sum(P)
      elif normalization == "point-wise":
          P = sp.diags(np.asarray(1 / P.sum(axis=1)).ravel()) @ P
  
      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 2 for calling a global function with example usage: joint_probabilities_nn(neighbors, distances, perplexities, symmetrize, normalization, n_reference_samples, n_jobs) and returns: P