code: def test_check_shape():
      ap = AveragePrecision()
  
      with pytest.raises(
          ValueError, match=r"Predictions should be of shape"
      ):
          ap._check_shape((torch.tensor(0), torch.tensor(0)))
  
      with pytest.raises(
          ValueError, match=r"Predictions should be of shape"
      ):
          ap._check_shape((torch.rand(4, 3, 1), torch.rand(4, 3)))
  
      with pytest.raises(
          ValueError, match=r"Targets should be of shape"
      ):
          ap._check_shape((torch.rand(4, 3), torch.rand(4, 3, 1)))
  
imports: import os
  from unittest.mock import patch
  import pytest
  import sklearn
  import torch
  from sklearn.metrics import average_precision_score
  import ignite.distributed
  from ignite.contrib.metrics import AveragePrecision
  from ignite.engine import Engine
  from ignite.exceptions import NotComputableError
label_desc: Use image node_id 5 for calling a global function with example usage: test_check_shape() without return types