code: def test_autoaugment__op_apply_shear(interpolation, mode):
      # We check that torchvision's implementation of shear is equivalent
      # to official CIFAR10 autoaugment implementation:
      # https://github.com/tensorflow/models/blob/885fda091c46c59d6c7bb5c7e760935eacc229da/research/autoaugment/augmentation_transforms.py#L273-L290
      image_size = 32
  
      def shear(pil_img, level, mode, resample):
          if mode == "X":
              matrix = (1, level, 0, 0, 1, 0)
          elif mode == "Y":
              matrix = (1, 0, 0, level, 1, 0)
          return pil_img.transform(
              (image_size, image_size),
              PIL.Image.AFFINE,
              matrix,
              resample=resample,
          )
  
      t_img, pil_img = _create_data(image_size, image_size)
  
      resample_pil = {
          F.InterpolationMode.NEAREST: PIL.Image.NEAREST,
          F.InterpolationMode.BILINEAR: PIL.Image.BILINEAR,
      }[interpolation]
  
      level = 0.3
      expected_out = shear(
          pil_img, level, mode=mode, resample=resample_pil
      )
  
      # Check pil output vs expected pil
      out = _apply_op(
          pil_img,
          op_name=f"Shear{mode}",
          magnitude=level,
          interpolation=interpolation,
          fill=0,
      )
      assert out == expected_out
  
      if interpolation == F.InterpolationMode.BILINEAR:
          # We skip bilinear mode for tensors as
          # affine transformation results are not exactly the same
          # between tensors and pil images
          # MAE as around 1.40
          # Max Abs error can be 163 or 170
          return
  
      # Check tensor output vs expected pil
      out = _apply_op(
          t_img,
          op_name=f"Shear{mode}",
          magnitude=level,
          interpolation=interpolation,
          fill=0,
      )
      _assert_approx_equal_tensor_to_pil(out, expected_out)
  
imports: import os
  import sys
  import numpy
  import PIL.Image
  import pytest
  import torch
  from common_utils import _assert_approx_equal_tensor_to_pil, _assert_equal_tensor_to_pil, _create_data, _create_data_batch, assert_equal, cpu_and_cuda, float_dtypes, get_tmp_dir, int_dtypes
  from torchvision import transforms
  from torchvision.transforms import functional, InterpolationMode
  from torchvision.transforms.autoaugment import _apply_op
label_desc: Use image node_id 35 for calling a global function with example usage: test_autoaugment__op_apply_shear(interpolation, mode) and returns: pil_img