class_docstr: Video Transformer model for multi-class classification.
class_docstr_tok: ["Video","Transformer","model","for","multi-class","classification","."]
docstr: Returns sigmoid cross entropy loss with an L2 penalty on the weights.
  
  Args:
    logits: Output of model in shape [batch, length, num_classes]. Optionally,
      this can also be a dictionary with logits for individual modalities.
    batch: Batch of data that has 'label' and optionally 'batch_mask'.
    model_params: Parameters of the model, for optionally applying
      regularization.
  
  Returns:
    Total loss.
code: def loss_function(
      self,
      logits: jnp.ndarray,
      batch: base_model.Batch,
      model_params: Optional[jnp.ndarray] = None,
  ) -> float:
      """Returns sigmoid cross entropy loss with an L2 penalty on the weights.
  
      Args:
        logits: Output of model in shape [batch, length, num_classes]. Optionally,
          this can also be a dictionary with logits for individual modalities.
        batch: Batch of data that has 'label' and optionally 'batch_mask'.
        model_params: Parameters of the model, for optionally applying
          regularization.
  
      Returns:
        Total loss.
      """
      weights = batch.get("batch_mask")
      labels = batch["label"]
  
      assert self.dataset_meta_data.get("target_is_onehot", False)
  
      label_weights = self.dataset_meta_data.get("class_weights", None)
      if self.config.model.classifier in ["onetoken"]:
          if isinstance(labels, dict):
              assert "all" in labels, "mixmod must be turned off."
              labels = labels["all"]
          sig_ce_loss = base_model_utils.weighted_sigmoid_cross_entropy(
              logits["onetoken"],
              labels,
              weights,
              label_weights=label_weights,
              label_smoothing=self.config.get("label_smoothing"),
          )
      elif isinstance(logits, dict):
          sig_ce_loss = []
          for modality in logits:
              sig_ce_loss.append(
                  base_model_utils.weighted_sigmoid_cross_entropy(
                      logits[modality],
                      labels[modality],
                      weights,
                      label_weights=label_weights,
                      label_smoothing=self.config.get(
                          "label_smoothing"
                      ),
                  )
              )
          sig_ce_loss = jnp.mean(jnp.array(sig_ce_loss))
      else:
          if isinstance(labels, dict):
              assert "all" in labels, "mixmod must be turned off."
              labels = labels["all"]
          sig_ce_loss = base_model_utils.weighted_sigmoid_cross_entropy(
              logits,
              labels,
              weights,
              label_weights=label_weights,
              label_smoothing=self.config.get("label_smoothing"),
          )
      if self.config.get("l2_decay_factor") is None:
          total_loss = sig_ce_loss
      else:
          l2_loss = base_model_utils.l2_regularization(model_params)
          total_loss = (
              sig_ce_loss + 0.5 * self.config.l2_decay_factor * l2_loss
          )
      return total_loss
  
imports: import functools
  import re
  from typing import Any, Callable, Dict, Optional, Sequence, Tuple
  from absl import logging
  import flax
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.common_lib import debug_utils
  from scenic.model_lib.base_models import base_model
  from scenic.model_lib.base_models import classification_model
  from scenic.model_lib.base_models import model_utils
  from scenic.model_lib.base_models.classification_model import ClassificationModel
  from scenic.model_lib.layers import nn_layers
  from scenic.projects.av_mae import model_utils
  from scenic.projects.baselines import vit
  from scenic.projects.mbt import model
  from scenic.projects.vivit import model_utils
  import scipy
label_desc: Use image node_id 3 for calling the MBTMultilabelClassificationModel obj's underlying member method code with example usage: obj.loss_function(logits, batch, model_params) and returns: total_loss