class_docstr: The standalone confusion matrix metric.
  
  Instances of this metric keep track of the confusion matrix by receiving a
  pair of "ground truth" and "prediction" Tensors describing the labels of a
  minibatch. Those two tensors can both contain plain labels or
  one-hot/logit vectors.
  
  The result is the unnormalized running confusion matrix.
  
  Beware that by default the confusion matrix size will depend on the value of
  the maximum label as detected by looking at both the ground truth and
  predictions Tensors. When passing one-hot/logit vectors, this
  metric will try to infer the number of classes from the vector sizes.
  Otherwise, the maximum label value encountered in the truth/prediction
  Tensors will be used.
  
  If the user sets the `num_classes`, then the confusion matrix will always be
  of size `num_classes, num_classes`. Whenever a prediction or label tensor is
  provided as logits, only the first `num_classes` units will be considered in
  the confusion matrix computation. If they are provided as numerical labels,
  each of them has to be smaller than `num_classes`.
  
  The reset method will bring the metric to its initial state. By default
  this metric in its initial state will return an empty Tensor.
class_docstr_tok: ["The","standalone","confusion","matrix","metric",".","Instances","of","this","metric","keep","track","of","the","confusion","matrix","by","receiving","a","pair","of","``","ground","truth","''","and","``","prediction","''","Tensors","describing","the","labels","of","a","minibatch",".","Those","two","tensors","can","both","contain","plain","labels","or","one-hot\/logit","vectors",".","The","result","is","the","unnormalized","running","confusion","matrix",".","Beware","that","by","default","the","confusion","matrix","size","will","depend","on","the","value","of","the","maximum","label","as","detected","by","looking","at","both","the","ground","truth","and","predictions","Tensors",".","When","passing","one-hot\/logit","vectors",",","this","metric","will","try","to","infer","the","number","of","classes","from","the","vector","sizes",".","Otherwise",",","the","maximum","label","value","encountered","in","the","truth\/prediction","Tensors","will","be","used",".","If","the","user","sets","the","`","num_classes","`",",","then","the","confusion","matrix","will","always","be","of","size","`","num_classes",",","num_classes","`",".","Whenever","a","prediction","or","label","tensor","is","provided","as","logits",",","only","the","first","`","num_classes","`","units","will","be","considered","in","the","confusion","matrix","computation",".","If","they","are","provided","as","numerical","labels",",","each","of","them","has","to","be","smaller","than","`","num_classes","`",".","The","reset","method","will","bring","the","metric","to","its","initial","state",".","By","default","this","metric","in","its","initial","state","will","return","an","empty","Tensor","."]
code: def nan_to_num(matrix: Tensor) -> Tensor:
      # if version.parse(torch.__version__) >= version.parse("1.8.0"):
      #    # noinspection PyUnresolvedReferences
      #    return torch.nan_to_num(matrix)
  
      numpy_ndarray = matrix.numpy()
      numpy_ndarray = np.nan_to_num(numpy_ndarray)
      return torch.tensor(numpy_ndarray, dtype=matrix.dtype)
  
imports: from matplotlib.figure import Figure
  from numpy import arange
  from typing_extensions import Literal
  from typing import Any, Callable, Iterable, Union, Optional, TYPE_CHECKING, List
  import wandb
  import numpy
  import torch
  from PIL.Image import Image
  from torch import Tensor
  from torch.nn.functional import pad
  from avalanche.benchmarks import NCScenario
  from avalanche.evaluation import PluginMetric, Metric
  from avalanche.evaluation.metric_results import AlternativeValues, MetricValue, MetricResult
  from avalanche.evaluation.metric_utils import default_cm_image_creator, phase_and_task, stream_type
label_desc: Use image node_id 6 for calling the ConfusionMatrix obj's underlying member method code with example usage: obj.nan_to_num(matrix) and returns: torch