code: def test_padding(method, side):
      np.random.seed(0)
  
      for _ in range(100):
          X_size = np.random.randint(low=10, high=1000)
          W_size = np.random.randint(low=2, high=X_size - 1)
  
          X = np.random.randint(low=0, high=10, size=X_size)
          W = np.random.randint(low=0, high=10, size=W_size)
  
          X_pad = SpectralResidual.pad_same(
              X=X, W=W, method=method, side=side
          )
          X_conv = np.convolve(X_pad, W, "valid")
          assert X_conv.shape[0] == X_size
  
          # length of the padding for laterals
          pad_right = (W_size - 1) // 2
          pad_left = W_size - 1 - pad_right
  
          if method == "constant":
              if side == "left":
                  assert np.all(X_pad[: W_size - 1] == 0)
              elif side == "right":
                  assert np.all(X_pad[-W_size + 1 :] == 0)
              else:
                  if pad_left > 0:
                      assert np.all(X_pad[:pad_left] == 0)
                  if pad_right > 0:
                      assert np.all(X_pad[-pad_right:] == 0)
  
          elif method == "replicate":
              if side == "left":
                  assert np.all(X_pad[: W_size - 1] == X[0])
              elif side == "right":
                  assert np.all(X_pad[-W_size + 1 :] == X[-1])
              else:
                  if pad_left > 0:
                      assert np.all(X_pad[:pad_left] == X[0])
                  if pad_right > 0:
                      assert np.all(X_pad[-pad_right:] == X[-1])
          else:
              if side == "left":
                  assert np.all(
                      X_pad[: W_size - 1] == X[1:W_size][::-1]
                  )
              elif side == "right":
                  assert np.all(
                      X_pad[-W_size + 1 :] == X[-2 : -W_size - 1 : -1]
                  )
              else:
                  if pad_left > 0:
                      assert np.all(
                          X_pad[:pad_left] == X[1 : pad_left + 1][::-1]
                      )
                  if pad_right > 0:
                      assert np.all(
                          X_pad[-pad_right:]
                          == X[-pad_right - 1 : -1][::-1]
                      )
  
imports: import pytest
  import numpy
  from alibi_detect.od import SpectralResidual
  from alibi_detect.version import __version__
label_desc: Use image node_id 3 for calling a global function with example usage: test_padding(method, side) without return types