class_docstr: Computes the confusion matrix and is based on `FCN <https://github.com/shelhamer/fcn.berkeleyvision.org/blob/master/score.py>`_
code: def compute(
      self,
  ) -> Union[Number, Dict[str, Union[Number, List[Number]]]]:
      if self.confusion_mat is None:
          print("Confusion matrix is None. Check code")
          return None
  
      h = self.confusion_mat.float()
  
      metrics: Dict[str, Tensor] = {}
      metrics["accuracy_global"] = torch.diag(h).sum() / h.sum()
      diag_h = torch.diag(h)
      metrics["class_accuracy"] = diag_h / h.sum(1)
      metrics["mean_class_accuracy"] = metrics["class_accuracy"].mean()
      metrics["iou"] = diag_h / (h.sum(1) + h.sum(0) - diag_h)
      metrics["mean_iou"] = metrics["iou"].mean()
      metrics["confusion"] = self.confusion_mat
  
      # Making sure all values are converted to Python values
      metrics = {
          k: v.detach().cpu().tolist() for k, v in metrics.items()
      }
      return metrics
  
file_path: ml-cvnets/metrics/confusion_mat.py
imports: from numbers import Number
  from typing import Any, Dict, List, Optional, Union
  import torch
  from torch import Tensor
  from metrics import METRICS_REGISTRY
  from metrics.metric_base import BaseMetric
  from utils.tensor_utils import reduce_tensor_sum
label_desc: Use image node_id 3 for calling the ConfusionMatrix obj's underlying member method code with example usage: obj.compute() and returns: metrics, None