code: def kl_divergence_fft(
      embedding,
      P,
      dof,
      fft_params,
      reference_embedding=None,
      should_eval_error=False,
      n_jobs=1,
      **_,
  ):
      gradient = np.zeros_like(embedding, dtype=np.float64, order="C")
  
      # Compute negative gradient.
      if embedding.ndim == 1 or embedding.shape[1] == 1:
          if reference_embedding is not None:
              sum_Q = _tsne.estimate_negative_gradient_fft_1d_with_grid(
                  embedding.ravel(),
                  gradient.ravel(),
                  reference_embedding.interp_coeffs,
                  reference_embedding.box_x_lower_bounds,
                  fft_params["n_interpolation_points"],
                  dof=dof,
              )
          else:
              sum_Q = _tsne.estimate_negative_gradient_fft_1d(
                  embedding.ravel(),
                  gradient.ravel(),
                  **fft_params,
                  dof=dof,
              )
      elif embedding.shape[1] == 2:
          if reference_embedding is not None:
              sum_Q = _tsne.estimate_negative_gradient_fft_2d_with_grid(
                  embedding,
                  gradient,
                  reference_embedding.interp_coeffs,
                  reference_embedding.box_x_lower_bounds,
                  reference_embedding.box_y_lower_bounds,
                  fft_params["n_interpolation_points"],
                  dof=dof,
              )
          else:
              sum_Q = _tsne.estimate_negative_gradient_fft_2d(
                  embedding, gradient, **fft_params, dof=dof
              )
      else:
          raise RuntimeError(
              "Interpolation based t-SNE for >2 dimensions is currently "
              "unsupported (and generally a bad idea)"
          )
  
      # The positive gradient function needs a reference embedding always
      if reference_embedding is None:
          reference_embedding = embedding
  
      # Compute positive gradient
      sum_P, kl_divergence_ = _tsne.estimate_positive_gradient_nn(
          P.indices,
          P.indptr,
          P.data,
          embedding,
          reference_embedding,
          gradient,
          dof,
          num_threads=n_jobs,
          should_eval_error=should_eval_error,
      )
  
      if should_eval_error:
          kl_divergence_ += sum_P * np.log(sum_Q + EPSILON)
  
      return kl_divergence_, gradient
  
imports: import inspect
  import logging
  import multiprocessing
  from collections.abc import Iterable
  from types import SimpleNamespace
  from time import time
  import numpy
  from sklearn.base import BaseEstimator
  from openTSNE import _tsne
  from openTSNE import initialization
  from openTSNE.affinity import Affinities, MultiscaleMixture
  from openTSNE.quad_tree import QuadTree
  from openTSNE import utils
label_desc: Use image node_id 6 for calling a global function with example usage: kl_divergence_fft(embedding, P, dof, fft_params, reference_embedding, should_eval_error, n_jobs) and returns: kl_divergence_,  gradient