class_docstr: Helper class to compute the top_1 and top_5 accuracies
code: def from_batch(
      cls, predictions: torch.Tensor, targets: torch.Tensor
  ) -> "Accuracies":
      correct = predictions.eq(targets.data.view(-1, 1))
      top1 = correct.narrow(dim=1, start=0, length=1).sum().item()
      if correct.shape[1] >= 5:
          top5 = correct.narrow(dim=1, start=0, length=5).sum().item()
      else:
          top5 = 0.0
      return Accuracies(
          correct_top_1=top1, correct_top_5=top5, total=targets.size(0)
      )
  
imports: import logging
  from typing import List, NamedTuple
  import numpy
  import torch
  from torch import nn
  from vissl.config import AttrDict
  from vissl.hooks import default_hook_generator
  from vissl.models.model_helpers import get_trunk_output_feature_names
  from vissl.utils.checkpoint import get_checkpoint_folder
  from vissl.utils.distributed_launcher import create_submitit_executor, launch_distributed
  from vissl.utils.env import set_env_vars
  from vissl.utils.extract_features_utils import ExtractedFeaturesLoader
  from vissl.utils.hydra_config import print_cfg
  from vissl.utils.io import save_file
  from vissl.utils.logger import setup_logging, shutdown_logging
label_desc: Use image node_id 2 for calling the Accuracies obj's underlying member method code with example usage: obj.from_batch(cls, predictions, targets) and returns: Accuracies