class_docstr: An abstraction of meter for evaluating video models.
  
  Video-level metric is computed by averaging clip-level predictions and
  compare the result with video-level groundtruth label.
  
  This meter abstraction can wrap conventional classy meters by passing
  averaged clip-level predictions to the meter needed for video level metrics.
docstr: Updates any internal state of meter with new model output and target.
  
  Args:
      model_output: tensor of shape (B * clips_per_video, C) where each value is
                    either logit or class probability.
      target:       tensor of shape (B * clips_per_video).
      is_train     if True, it is training stage when meter is updated
  
      Note: For binary classification, C=2.
docstr_tok: ["Updates","any","internal","state","of","meter","with","new","model","output","and","target",".","Args",":","model_output",":","tensor","of","shape","(","B","*","clips_per_video",",","C",")","where","each","value","is","either","logit","or","class","probability",".","target",":","tensor","of","shape","(","B","*","clips_per_video",")",".","is_train","if","True",",","it","is","training","stage","when","meter","is","updated","Note",":","For","binary","classification",",","C=2","."]
code: def update(self, model_output, target, is_train, **kwargs):
      """Updates any internal state of meter with new model output and target.
  
      Args:
          model_output: tensor of shape (B * clips_per_video, C) where each value is
                        either logit or class probability.
          target:       tensor of shape (B * clips_per_video).
          is_train     if True, it is training stage when meter is updated
  
          Note: For binary classification, C=2.
      """
      num_clips = len(model_output)
      clips_per_video = (
          self._clips_per_video_train
          if is_train
          else self._clips_per_video_test
      )
  
      if not num_clips % clips_per_video == 0:
          logging.info(
              "Skip meter update. Because for video model testing, batch size "
              "is expected to be a multplier of No. of clips per video. "
              "num_clips: %d, clips_per_video: %d"
              % (num_clips, clips_per_video)
          )
          return
  
      num_videos = num_clips // clips_per_video
      for i in range(num_videos):
          clip_labels = target[
              i * clips_per_video : (i + 1) * clips_per_video
          ]
          if clip_labels.ndim == 1:
              # single label
              assert (
                  len(torch.unique(clip_labels)) == 1
              ), "all clips from the same video should have same label"
          elif clip_labels.ndim == 2:
              # multi-hot label
              for j in range(1, clip_labels.shape[0]):
                  assert torch.equal(
                      clip_labels[0], clip_labels[j]
                  ), "all clips from the same video should have the same labels"
          else:
              raise ValueError(
                  "dimension of clip label matrix should be either 1 or 2"
              )
  
      video_model_output = torch.mean(
          torch.reshape(
              model_output, (num_videos, clips_per_video, -1)
          ),
          1,
      )
      video_target = target[::clips_per_video]
      self.meter.update(video_model_output, video_target)
  
file_path: ClassyVision/classy_vision/meters/video_meter.py
imports: import logging
  import torch
  from classy_vision.meters import ClassyMeter
label_desc: Use image node_id 7 for calling the VideoMeter obj's underlying member method code with example usage: obj.update(model_output, target, is_train) without return types