docstr: Cross-entropy between softmax outputs of the teacher and student networks.
  student_patch_tokens: (B, N, D) tensor
  teacher_patch_tokens: (B, N, D) tensor
  student_masks_flat: (B, N) tensor
docstr_tok: ["Cross-entropy","between","softmax","outputs","of","the","teacher","and","student","networks",".","student_patch_tokens",":","(","B",",","N",",","D",")","tensor","teacher_patch_tokens",":","(","B",",","N",",","D",")","tensor","student_masks_flat",":","(","B",",","N",")","tensor"]
code: def forward(
      self,
      student_patch_tokens,
      teacher_patch_tokens,
      student_masks_flat,
  ):
      """
      Cross-entropy between softmax outputs of the teacher and student networks.
      student_patch_tokens: (B, N, D) tensor
      teacher_patch_tokens: (B, N, D) tensor
      student_masks_flat: (B, N) tensor
      """
      t = teacher_patch_tokens
      s = student_patch_tokens
      loss = torch.sum(
          t * F.log_softmax(s / self.student_temp, dim=-1), dim=-1
      )
      loss = torch.sum(
          loss * student_masks_flat.float(), dim=-1
      ) / student_masks_flat.sum(dim=-1).clamp(min=1.0)
      return -loss.mean()
  
file_path: dinov2/dinov2/loss/ibot_patch_loss.py
imports: import torch
  import torch.distributed
  import torch.nn.functional
  from torch import nn
  import logging
label_desc: Use image node_id 4 for calling the iBOTPatchLoss obj's underlying member method code with example usage: obj.forward(student_patch_tokens, teacher_patch_tokens, student_masks_flat) and returns: unknown