class_docstr: Wrapper around the loss of IBOT (https://arxiv.org/pdf/2111.07832.pdf)
  
  Allows to feed the correct configuration to IBOTCriterion class (below)
  which implement the IBOT loss entirely decoupled from VISSL
docstr: Check if class token predictions match across local views:
  - on masked patches
  - student vs teacher
  
  Args:
      teacher_global_patches: (batch_size * num_global_crops, feat_map_size, out_dim)
      student_global_patches: (batch_size * num_global_crops, feat_map_size, out_dim)
      student_mask: (batch_size * num_global_crops, H, W)
docstr_tok: ["Check","if","class","token","predictions","match","across","local","views",":","-","on","masked","patches","-","student","vs","teacher","Args",":","teacher_global_patches",":","(","batch_size","*","num_global_crops",",","feat_map_size",",","out_dim",")","student_global_patches",":","(","batch_size","*","num_global_crops",",","feat_map_size",",","out_dim",")","student_mask",":","(","batch_size","*","num_global_crops",",","H",",","W",")"]
code: def _extract_ptc_token_accuracy(
      self, teacher_global_patches, student_global_patches, student_mask
  ):
      """
      Check if class token predictions match across local views:
      - on masked patches
      - student vs teacher
  
      Args:
          teacher_global_patches: (batch_size * num_global_crops, feat_map_size, out_dim)
          student_global_patches: (batch_size * num_global_crops, feat_map_size, out_dim)
          student_mask: (batch_size * num_global_crops, H, W)
      """
  
      # TODO (IBOT) - provide faster implementation where we avoid all_gather masked info
      teacher_pred = teacher_global_patches.max(dim=-1)[1].view(-1)
      student_pred = student_global_patches.max(dim=-1)[1].view(-1)
      teacher_pred = concat_all_gather(teacher_pred)
      student_pred = concat_all_gather(student_pred)
      student_mask = concat_all_gather(student_mask.view(-1))
  
      teacher_pred = torch.masked_select(teacher_pred, student_mask)
      student_pred = torch.masked_select(student_pred, student_mask)
      acc = (
          teacher_pred == student_pred
      ).sum() / student_mask.sum().clamp(min=1.0)
      return acc.item()
  
imports: import logging
  import pprint
  from typing import List
  import numpy
  import torch
  import torch.distributed
  import torch.nn
  import torch.nn.functional
  from classy_vision.losses import ClassyLoss, register_loss
  from fairscale.nn import FullyShardedDataParallel
  from vissl.config import AttrDict
  from vissl.models.model_helpers import get_no_ddp_model
  from vissl.utils.distributed_utils import concat_all_gather
label_desc: Use image node_id 8 for calling the IBOTLoss obj's underlying member method code with example usage: obj._extract_ptc_token_accuracy(teacher_global_patches, student_global_patches, student_mask) and returns: acc