code: def dedup_by_vid(
      logits: np.ndarray,
      labels: np.ndarray,
      batch_masks: np.ndarray,
      vids: np.ndarray,
      frame_masks: Optional[np.ndarray] = None,
  ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
      """Dedups by video ids.
  
      Args:
        logits: Predicted class logits in shape (num_videos, num_classes) if
          frame_masks is None or in shape (num_videos, num_frames, num_classes)
          otherwise.
        labels: Multihot vectors representing the ground truth labels in shape
          (num_videos, num_classes) if frame_masks is None or in shape (num_videos,
          num_frames, num_classes) otherwise.
        batch_masks: Batch masks in shape (num_videos,).
        vids: Video ids in shape (num_videos,).
        frame_masks: Frame masks in shape (num_videos, num_frames).
  
      Returns:
        deduped logits in shape (N, num_classes).
        deduped labels in shape (N, num_classes).
        deduped video ids in shape (N,).
      """
  
      batch_masks = batch_masks.astype(bool)
      vids = vids[batch_masks]
      logits = logits[batch_masks]
      labels = labels[batch_masks]
      if frame_masks is not None:
          frame_masks = frame_masks.astype(bool)
          frame_masks = frame_masks[batch_masks]
      vid_set = set()
      deduped_logits, deduped_labels, deduped_vids = [], [], []
      for idx, vid in enumerate(vids):
          if vid in vid_set:
              continue
          if frame_masks is None:
              deduped_logits.append(logits[idx][np.newaxis, :])
              deduped_labels.append(labels[idx][np.newaxis, :])
          else:
              frame_mask = frame_masks[idx]
              deduped_logits.append(logits[idx][frame_mask])
              deduped_labels.append(labels[idx][frame_mask])
          vid_set.add(vid)
          deduped_vids.append(vid)
      return (
          np.concatenate(deduped_logits, axis=0),
          np.concatenate(deduped_labels, axis=0),
          np.array(deduped_vids),
      )
  
file_path: scenic/scenic/projects/unloc/postprocessing_utils.py
imports: from typing import Any, List, Optional, Tuple, Union
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.projects.unloc import model_utils
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: dedup_by_vid(logits, labels, batch_masks, vids, frame_masks) and returns: np,  np,  np