class_docstr: Expected Calibration Error (ECE)
  
  Args:
      n_cls (int): number of existing target classes
      n_bins (int): number of bins to discretize the uncertainty.
  
  References:
      https://arxiv.org/pdf/1706.04599.pdf
class_docstr_tok: ["Expected","Calibration","Error","(","ECE",")","Args",":","n_cls","(","int",")",":","number","of","existing","target","classes","n_bins","(","int",")",":","number","of","bins","to","discretize","the","uncertainty",".","References",":","https",":","\/\/arxiv.org\/pdf\/1706.04599.pdf"]
docstr: Updating the true positive (tp) and number of samples in each bin.
  
  Args:
      output (tensor): logits or predictions of model
      target (tensor): labels
docstr_tok: ["Updating","the","true","positive","(","tp",")","and","number","of","samples","in","each","bin",".","Args",":","output","(","tensor",")",":","logits","or","predictions","of","model","target","(","tensor",")",":","labels"]
code: def update(self, output=None, target=None):
      """
      Updating the true positive (tp) and number of samples in each bin.
  
      Args:
          output (tensor): logits or predictions of model
          target (tensor): labels
      """
      output = output.detach().cpu().numpy()
      target = target.detach().cpu().numpy()
      output = to_prob(output)
  
      # this is to make sure handling 1.0 value confidence to be assigned to a bin
      output = np.clip(output, 0, 0.9999)
  
      for pred, t in zip(output, target):
          t = int(t)  # Force the conversion
          conf, p_cls = pred.max(), pred.argmax()
          bin_id = int(math.floor(conf * self.n_bins))
          self.samples[t, bin_id] += 1
          self.tp[t, bin_id] += int(p_cls == t)
          self.conf_agg[t, bin_id] += conf
  
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 2 for calling the ECE_PerCLs obj's underlying member method code with example usage: obj.update(output, target) without return types