class_docstr: Encapsulates model + loss + optimizer + metrics in a PL module
class_docstr_tok: ["Encapsulates","model","+","loss","+","optimizer","+","metrics","in","a","PL","module"]
code: def rate_loss(
      self, video: VideoData, rate_args, per_frame: bool = True
  ) -> Tensor:
      # average over batch dim but not over frame within the video
      B, T, _, H, W = video.shape
      num_pixels = B * H * W if per_frame else B * H * W * T
      total_bits = self.model.compute_rate(
          *rate_args, per_frame=per_frame
      )
      return total_bits / num_pixels
  
imports: from typing import Any, List, Optional, Tuple, Union
  import hydra
  import pytorch_lightning
  import torch
  import torch.nn.functional
  from datamodules.video_data_api import VideoData
  from model_pipeline import VCTPipeline
  from omegaconf import DictConfig
  from torch import Tensor
  from torchmetrics.functional import peak_signal_noise_ratio
  from utils.hydra_tools import OmegaConf
label_desc: Use image node_id 3 for calling the VCTModule obj's underlying member method code with example usage: obj.rate_loss(video, rate_args, per_frame) and returns: unknown