code: def _optimize_layout_euclidean_single_epoch(
      head_embedding,
      tail_embedding,
      head,
      tail,
      n_vertices,
      epochs_per_sample,
      a,
      b,
      rng_state,
      gamma,
      dim,
      move_other,
      alpha,
      epochs_per_negative_sample,
      epoch_of_next_negative_sample,
      epoch_of_next_sample,
      n,
      densmap_flag,
      dens_phi_sum,
      dens_re_sum,
      dens_re_cov,
      dens_re_std,
      dens_re_mean,
      dens_lambda,
      dens_R,
      dens_mu,
      dens_mu_tot,
  ):
      for i in numba.prange(epochs_per_sample.shape[0]):
          if epoch_of_next_sample[i] <= n:
              j = head[i]
              k = tail[i]
  
              current = head_embedding[j]
              other = tail_embedding[k]
  
              dist_squared = rdist(current, other)
  
              if densmap_flag:
                  phi = 1.0 / (1.0 + a * pow(dist_squared, b))
                  dphi_term = (
                      a
                      * b
                      * pow(dist_squared, b - 1)
                      / (1.0 + a * pow(dist_squared, b))
                  )
  
                  q_jk = phi / dens_phi_sum[k]
                  q_kj = phi / dens_phi_sum[j]
  
                  drk = q_jk * (
                      (1.0 - b * (1 - phi)) / np.exp(dens_re_sum[k])
                      + dphi_term
                  )
                  drj = q_kj * (
                      (1.0 - b * (1 - phi)) / np.exp(dens_re_sum[j])
                      + dphi_term
                  )
  
                  re_std_sq = dens_re_std * dens_re_std
                  weight_k = (
                      dens_R[k]
                      - dens_re_cov
                      * (dens_re_sum[k] - dens_re_mean)
                      / re_std_sq
                  )
                  weight_j = (
                      dens_R[j]
                      - dens_re_cov
                      * (dens_re_sum[j] - dens_re_mean)
                      / re_std_sq
                  )
  
                  grad_cor_coeff = (
                      dens_lambda
                      * dens_mu_tot
                      * (weight_k * drk + weight_j * drj)
                      / (dens_mu[i] * dens_re_std)
                      / n_vertices
                  )
  
              if dist_squared > 0.0:
                  grad_coeff = -2.0 * a * b * pow(dist_squared, b - 1.0)
                  grad_coeff /= a * pow(dist_squared, b) + 1.0
              else:
                  grad_coeff = 0.0
  
              for d in range(dim):
                  grad_d = clip(grad_coeff * (current[d] - other[d]))
  
                  if densmap_flag:
                      # FIXME: grad_cor_coeff might be referenced before assignment
  
                      grad_d += clip(
                          2 * grad_cor_coeff * (current[d] - other[d])
                      )
  
                  current[d] += grad_d * alpha
                  if move_other:
                      other[d] += -grad_d * alpha
  
              epoch_of_next_sample[i] += epochs_per_sample[i]
  
              n_neg_samples = int(
                  (n - epoch_of_next_negative_sample[i])
                  / epochs_per_negative_sample[i]
              )
  
              for p in range(n_neg_samples):
                  k = tau_rand_int(rng_state) % n_vertices
  
                  other = tail_embedding[k]
  
                  dist_squared = rdist(current, other)
  
                  if dist_squared > 0.0:
                      grad_coeff = 2.0 * gamma * b
                      grad_coeff /= (0.001 + dist_squared) * (
                          a * pow(dist_squared, b) + 1
                      )
                  elif j == k:
                      continue
                  else:
                      grad_coeff = 0.0
  
                  for d in range(dim):
                      if grad_coeff > 0.0:
                          grad_d = clip(
                              grad_coeff * (current[d] - other[d])
                          )
                      else:
                          grad_d = 0
                      current[d] += grad_d * alpha
  
              epoch_of_next_negative_sample[i] += (
                  n_neg_samples * epochs_per_negative_sample[i]
              )
  
file_path: umap/umap/layouts.py
imports: import numpy
  import numba
  import umap.distances
  from umap.utils import tau_rand_int
  from tqdm.auto import tqdm
label_desc: Use image node_id 3 for calling a global function with example usage: _optimize_layout_euclidean_single_epoch(head_embedding, tail_embedding, head, tail, n_vertices, epochs_per_sample, a, b, rng_state, gamma, dim, move_other, alpha, epochs_per_negative_sample, epoch_of_next_negative_sample, epoch_of_next_sample, n, densmap_flag, dens_phi_sum, dens_re_sum, dens_re_cov, dens_re_std, dens_re_mean, dens_lambda, dens_R, dens_mu, dens_mu_tot) without return types