code: def hn_nce_loss_without_hardnegs(logits, alpha=1, beta=0, n=None):
      """Returns HN-NCE loss when *not* considering verb hard negatives."""
      # The weights will compare how similar is each text compared to the average
      ws = jnp.exp(
          beta * logits - jnp.max(beta * logits, axis=-1, keepdims=True)
      )
      # Zeroing the diagonal.
      ws = (1 != jnp.eye(logits.shape[0], logits.shape[1])) * ws
      # Substracting the mean of each row.
      if n is None:
          n = ws.shape[-1] - 1
      ws = n * ws / jnp.sum(ws, axis=-1, keepdims=True)
      exp_logits = jnp.exp(
          logits - jnp.max(logits, axis=-1, keepdims=True)
      )
      pos = jnp.diag(exp_logits)
      ws = ws * exp_logits
      loss = -jnp.log(pos / (alpha * pos + jnp.sum(ws, axis=-1)))
      return loss
  
file_path: scenic/scenic/projects/verbs_in_action/losses.py
imports: from typing import Tuple
  import flax.linen
  import jax.numpy
  import numpy
  from scenic.projects.verbs_in_action import utils
label_desc: Use image node_id 3 for calling a global function with example usage: hn_nce_loss_without_hardnegs(logits, alpha, beta, n) and returns: loss