code: def update(self, a, b):
      n = self.num_classes
      if self.mat is None:
          # 创建混淆矩阵
          self.mat = torch.zeros(
              (n, n), dtype=torch.int64, device=a.device
          )
      with torch.no_grad():
          # 寻找GT中为目标的像素索引
          k = (a >= 0) & (a < n)
          # 统计像素真实类别a[k]被预测成类别b[k]的个数(这里的做法很巧妙)
          inds = n * a[k].to(torch.int64) + b[k]
          self.mat += torch.bincount(inds, minlength=n**2).reshape(
              n, n
          )
  
imports: from collections import defaultdict, deque
  import datetime
  import time
  import torch
  import torch.distributed
  import errno
  import os
label_desc: Use image node_id 2 for calling the ConfusionMatrix obj's underlying member method code with example usage: obj.update(a, b) without return types