code: def frame_accuracy(
      logits: np.ndarray,
      label: np.ndarray,
      background_logit_threshold: float = 0.0,
  ) -> float:
      """Computes frame accuracy.
  
      We assume there are background samples where the labels are all zeros.
  
      Args:
        logits: Class logits in shape (N, num_classes).
        label: Multihot class labels in shape (N, num_classes).
        background_logit_threshold: If the max logit of an example is less than this
          value, this example is predicted as background.
  
      Returns:
        Accuracy computed as number of correctly predicted frames over total number
        of frames.
      """
      top1_idx = np.argmax(logits, axis=-1)
      background_label = np.sum(label, axis=-1) == 0
      pred_background = (
          np.max(logits, axis=-1) <= background_logit_threshold
      ).astype(np.int32)
  
      # Extracts the label at the highest logit index for each input.
      top1_correct = np.take_along_axis(
          label, top1_idx[..., None], axis=-1
      )
      top1_correct = np.squeeze(top1_correct)
      foreground_correct = ~pred_background.astype(bool) * top1_correct
  
      # Count correctly classified background samples.
      background_correct = pred_background * background_label
      correct = foreground_correct + background_correct
      return np.sum(correct) / len(logits)
  
file_path: scenic/scenic/projects/unloc/metrics.py
imports: from typing import Any, List, Union
  import jax.numpy
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: frame_accuracy(logits, label, background_logit_threshold) and returns: unknown