code: def test_pvtv2():
      """Test PVTv2 backbone."""
  
      with pytest.raises(TypeError):
          # Pretrained arg must be str or None.
          PyramidVisionTransformerV2(pretrained=123)
  
      # test pretrained image size
      with pytest.raises(AssertionError):
          PyramidVisionTransformerV2(pretrain_img_size=(224, 224, 224))
  
      # Test normal inference
      temp = torch.randn((1, 3, 32, 32))
      model = PyramidVisionTransformerV2()
      outs = model(temp)
      assert outs[0].shape == (1, 64, 8, 8)
      assert outs[1].shape == (1, 128, 4, 4)
      assert outs[2].shape == (1, 320, 2, 2)
      assert outs[3].shape == (1, 512, 1, 1)
  
      # Test abnormal inference size
      temp = torch.randn((1, 3, 31, 31))
      model = PyramidVisionTransformerV2()
      outs = model(temp)
      assert outs[0].shape == (1, 64, 8, 8)
      assert outs[1].shape == (1, 128, 4, 4)
      assert outs[2].shape == (1, 320, 2, 2)
      assert outs[3].shape == (1, 512, 1, 1)
  
      # Test abnormal inference size
      temp = torch.randn((1, 3, 112, 137))
      model = PyramidVisionTransformerV2()
      outs = model(temp)
      assert outs[0].shape == (1, 64, 28, 35)
      assert outs[1].shape == (1, 128, 14, 18)
      assert outs[2].shape == (1, 320, 7, 9)
      assert outs[3].shape == (1, 512, 4, 5)
  
imports: import pytest
  import torch
  from mmdet.models.backbones.pvt import PVTEncoderLayer, PyramidVisionTransformer, PyramidVisionTransformerV2
label_desc: Use image node_id 3 for calling a global function with example usage: test_pvtv2() without return types