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: Plot each bins, ideally this would be a diagonal line.
  
  Args:
      pth (str): if provided the figure will be saved under the given path
docstr_tok: ["Plot","each","bins",",","ideally","this","would","be","a","diagonal","line",".","Args",":","pth","(","str",")",":","if","provided","the","figure","will","be","saved","under","the","given","path"]
code: def plot(self, pth=None):
      """
      Plot each bins, ideally this would be a diagonal line.
  
      Args:
          pth (str): if provided the figure will be saved under the given path
      """
      import matplotlib.pyplot as plt
  
      accuracy = self._acc()
      # Plot the ECE
      fig, axs = plt.subplots(self.n_cls)
      for cls in range(self.n_cls):
          axs[cls].bar(
              np.linspace(0, 1, self.n_bins),
              accuracy[cls, :],
              align="edge",
              width=0.1,
          )
          axs[cls].plot([0, 1], [0, 1], "--", color="tab:gray")
          axs[cls].set_ylim(0, 1)
          axs[cls].set_xlim(0, 1)
          axs[cls].set_ylabel("Accuracy")
          axs[cls].set_xlabel("Uncertainty")
          axs[cls].grid()
      if pth:
          plt.savefig(pth)
          plt.close()
      else:
          plt.show()
  
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 6 for calling the ECE_PerCLs obj's underlying member method code with example usage: obj.plot(pth) without return types