class_docstr: computes the top first and top five accuracy for the model batch by
  batch.
  Args:
      average (bool): a way to output one single value for metrics
                      that are calculated in several trials.
      topk (tuple): the value of k for calculating the topk accuracy.
class_docstr_tok: ["computes","the","top","first","and","top","five","accuracy","for","the","model","batch","by","batch",".","Args",":","average","(","bool",")",":","a","way","to","output","one","single","value","for","metrics","that","are","calculated","in","several","trials",".","topk","(","tuple",")",":","the","value","of","k","for","calculating","the","topk","accuracy","."]
docstr: Update TP and support.
  
  Args:
      output (tensor): predictions of model
      target (tensor): labels
  
  Raises:
      ValueError if the first dimension of output and target don't match.
docstr_tok: ["Update","TP","and","support",".","Args",":","output","(","tensor",")",":","predictions","of","model","target","(","tensor",")",":","labels","Raises",":","ValueError","if","the","first","dimension","of","output","and","target","do","n't","match","."]
code: def update(self, output=None, target=None):
      """
      Update TP and support.
  
      Args:
          output (tensor): predictions of model
          target (tensor): labels
  
      Raises:
          ValueError if the first dimension of output and target don't match.
      """
      batch_size = target.shape[0]
      if not output.shape[0] == target.shape[0]:
          raise ValueError(
              f"Sizes of the output ({output.shape[0]}) and target "
              "({target.shape[0]}) don't match."
          )
      dim = 1
      predicted_indices = output.topk(
          self.maxk, dim, largest=True, sorted=True
      )[1]
  
      correct = predicted_indices.eq(
          target.view(-1, 1).expand_as(predicted_indices)
      )
  
      topk_acc = []
      for k in self.topk:
          correct_k = correct[:, :k].contiguous().view(-1).float().sum()
          topk_acc.append(float(correct_k.mul_(1.0 / batch_size)))
  
      if len(self.accuracy) == 0:
          self.accuracy = torch.FloatTensor(topk_acc).unsqueeze(0)
      else:
          self.accuracy = torch.cat(
              [self.accuracy, torch.FloatTensor(topk_acc).unsqueeze(0)],
              dim=0,
          )
  
imports: import dataclasses
  import math
  import warnings
  from collections import defaultdict
  import numpy
  import torch
  from sklearn.metrics import confusion_matrix, auc
  from baal.utils.array_utils import to_prob
label_desc: Use image node_id 3 for calling the Accuracy obj's underlying member method code with example usage: obj.update(output, target) without return types