code: def test_warning_on_nan():
      """Test that a warning is given if division by zero happens during normalization of confusion matrix."""
      preds = torch.randint(3, size=(20,))
      target = torch.randint(3, size=(20,))
  
      with pytest.warns(
          UserWarning,
          match=".* NaN values found in confusion matrix have been replaced with zeros.",
      ):
          multiclass_confusion_matrix(
              preds, target, num_classes=5, normalize="true"
          )
  
imports: from functools import partial
  import numpy
  import pytest
  import torch
  from scipy.special import expit
  from sklearn.metrics import confusion_matrix
  from torchmetrics.classification.confusion_matrix import BinaryConfusionMatrix, ConfusionMatrix, MulticlassConfusionMatrix, MultilabelConfusionMatrix
  from torchmetrics.functional.classification.confusion_matrix import binary_confusion_matrix, multiclass_confusion_matrix, multilabel_confusion_matrix
  from torchmetrics.metric import Metric
  from unittests import NUM_CLASSES, THRESHOLD
  from unittests.classification.inputs import _binary_cases, _multiclass_cases, _multilabel_cases
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester, inject_ignore_index, remove_ignore_index
label_desc: Use image node_id 5 for calling a global function with example usage: test_warning_on_nan() without return types