code: def test_average_parameter():
      with pytest.raises(
          ValueError,
          match="Argument average should be None or a boolean or one of values",
      ):
          Precision(average=1)
  
      pr = Precision(average="samples")
      with pytest.raises(
          ValueError,
          match=r"Argument average='samples' is incompatible with binary and multiclass input data.",
      ):
          pr.update(
              (
                  torch.randint(0, 2, size=(10,)).long(),
                  torch.randint(0, 2, size=(10,)).long(),
              )
          )
      assert pr._updated is False
  
      pr = Precision(average="samples")
      with pytest.raises(
          ValueError,
          match=r"Argument average='samples' is incompatible with binary and multiclass input data.",
      ):
          pr.update(
              (
                  torch.rand(10, 3),
                  torch.randint(0, 3, size=(10,)).long(),
              )
          )
      assert pr._updated is False
  
      pr = Precision(average=True)
      assert pr._average == "macro"
  
imports: import warnings
  import pytest
  import torch
  from sklearn.exceptions import UndefinedMetricWarning
  from sklearn.metrics import precision_score
  import ignite.distributed
  from ignite.exceptions import NotComputableError
  from ignite.metrics import Precision
label_desc: Use image node_id 2 for calling a global function with example usage: test_average_parameter() without return types