code: def _optimize_layout_generic_single_epoch(
      epochs_per_sample,
      epoch_of_next_sample,
      head,
      tail,
      head_embedding,
      tail_embedding,
      output_metric,
      output_metric_kwds,
      dim,
      alpha,
      move_other,
      n,
      epoch_of_next_negative_sample,
      epochs_per_negative_sample,
      rng_state,
      n_vertices,
      a,
      b,
      gamma,
  ):
      for i in range(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_output, grad_dist_output = output_metric(
                  current, other, *output_metric_kwds
              )
              _, rev_grad_dist_output = output_metric(
                  other, current, *output_metric_kwds
              )
  
              if dist_output > 0.0:
                  w_l = pow((1 + a * pow(dist_output, 2 * b)), -1)
              else:
                  w_l = 1.0
              grad_coeff = 2 * b * (w_l - 1) / (dist_output + 1e-6)
  
              for d in range(dim):
                  grad_d = clip(grad_coeff * grad_dist_output[d])
  
                  current[d] += grad_d * alpha
                  if move_other:
                      grad_d = clip(
                          grad_coeff * rev_grad_dist_output[d]
                      )
                      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_output, grad_dist_output = output_metric(
                      current, other, *output_metric_kwds
                  )
  
                  if dist_output > 0.0:
                      w_l = pow((1 + a * pow(dist_output, 2 * b)), -1)
                  elif j == k:
                      continue
                  else:
                      w_l = 1.0
  
                  grad_coeff = (
                      gamma * 2 * b * w_l / (dist_output + 1e-6)
                  )
  
                  for d in range(dim):
                      grad_d = clip(grad_coeff * grad_dist_output[d])
                      current[d] += grad_d * alpha
  
              epoch_of_next_negative_sample[i] += (
                  n_neg_samples * epochs_per_negative_sample[i]
              )
      return epoch_of_next_sample, epoch_of_next_negative_sample
  
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 6 for calling a global function with example usage: _optimize_layout_generic_single_epoch(epochs_per_sample, epoch_of_next_sample, head, tail, head_embedding, tail_embedding, output_metric, output_metric_kwds, dim, alpha, move_other, n, epoch_of_next_negative_sample, epochs_per_negative_sample, rng_state, n_vertices, a, b, gamma) and returns: epoch_of_next_sample,  epoch_of_next_negative_sample