code: def test_cm_precision():
      y_true, y_pred = np.random.randint(
          0, 10, size=(1000,)
      ), np.random.randint(0, 10, size=(1000,))
      th_y_true, th_y_logits = compute_th_y_true_y_logits(
          y_true, y_pred
      )
  
      true_pr = precision_score(
          y_true.reshape(-1), y_pred.reshape(-1), average="macro"
      )
  
      cm = ConfusionMatrix(num_classes=10)
      pr_metric = cmPrecision(cm, average=True)
  
      # Update metric
      output = (th_y_logits, th_y_true)
      cm.update(output)
  
      res = pr_metric.compute().numpy()
  
      assert pytest.approx(res) == true_pr
  
      true_pr = precision_score(
          y_true.reshape(-1), y_pred.reshape(-1), average=None
      )
      cm = ConfusionMatrix(num_classes=10)
      pr_metric = cmPrecision(cm, average=False)
  
      # Update metric
      output = (th_y_logits, th_y_true)
      cm.update(output)
  
      res = pr_metric.compute().numpy()
  
      assert np.all(res == true_pr)
  
imports: import os
  import numpy
  import pytest
  import torch
  from sklearn.metrics import accuracy_score, confusion_matrix, precision_score, recall_score
  import ignite.distributed
  from ignite.exceptions import NotComputableError
  from ignite.metrics import ConfusionMatrix, IoU, JaccardIndex, mIoU
  from ignite.metrics.confusion_matrix import cmAccuracy, cmPrecision, cmRecall, DiceCoefficient
label_desc: Use image node_id 14 for calling a global function with example usage: test_cm_precision() without return types