docstr: Check that Convolve returns values identical to those that SciPy produces.
docstr_tok: ["Check","that","Convolve","returns","values","identical","to","those","that","SciPy","produces","."]
code: def test_convolve(self, leading_dims, lengths, mode):
      """Check that Convolve returns values identical to those that SciPy produces."""
      L_x, L_y = lengths
  
      x = torch.rand(
          *(leading_dims + (L_x,)), dtype=self.dtype, device=self.device
      )
      y = torch.rand(
          *(leading_dims + (L_y,)), dtype=self.dtype, device=self.device
      )
  
      convolve = T.Convolve(mode=mode).to(self.device)
      actual = convolve(x, y)
  
      num_signals = (
          torch.tensor(leading_dims).prod() if leading_dims else 1
      )
      x_reshaped = x.reshape((num_signals, L_x))
      y_reshaped = y.reshape((num_signals, L_y))
      expected = [
          signal.convolve(
              x_reshaped[i].detach().cpu().numpy(),
              y_reshaped[i].detach().cpu().numpy(),
              mode=mode,
          )
          for i in range(num_signals)
      ]
      expected = torch.tensor(np.array(expected))
      expected = expected.reshape(leading_dims + (-1,))
  
      self.assertEqual(expected, actual)
  
imports: import math
  import random
  from unittest.mock import patch
  import numpy
  import torch
  import torchaudio.transforms
  from parameterized import param, parameterized
  from scipy import signal
  from torchaudio.functional import lfilter, preemphasis
  from torchaudio.functional.functional import _get_sinc_resample_kernel
  from torchaudio_unittest.common_utils import get_spectrogram, get_whitenoise, nested_params, TestBaseMixin
  from torchaudio_unittest.common_utils.psd_utils import psd_numpy
label_desc: Use image node_id 8 for calling the TransformsTestBase obj's underlying member method code with example usage: obj.test_convolve(leading_dims, lengths, mode) without return types