docstr: Apply the prepared filter to the specified axis of a nD signal x
code: def apply_filter(
      self,
      x,
      axis,
  ):
      """Apply the prepared filter to the specified axis of a nD signal x"""
  
      x = cupy.asarray(x, self._output_type)
  
      output_len = _output_len(
          self._h_len_orig, x.shape[axis], self._up, self._down
      )
      output_shape = list(x.shape)
      output_shape[axis] = output_len
      out = cupy.empty(output_shape, dtype=self._output_type, order="C")
      axis = axis % x.ndim
  
      # Precompute variables on CPU
      x_shape_a = x.shape[axis]
      h_per_phase = len(self._h_trans_flip) // self._up
      padded_len = (
          x.shape[axis] + (len(self._h_trans_flip) // self._up) - 1
      )
  
      if out.ndim == 1:
          threadsperblock, blockspergrid = _get_tpb_bpg()
  
          kernel = UPFIRDN_MODULE.get_function(
              f"_cupy_upfirdn1D_{out.dtype.name}"
          )
          kernel(
              ((x.shape[0] + 128 - 1) // 128,),
              (128,),
              (
                  x,
                  self._h_trans_flip,
                  self._up,
                  self._down,
                  axis,
                  x_shape_a,
                  h_per_phase,
                  padded_len,
                  out,
                  out.shape[0],
              ),
          )
  
      elif out.ndim == 2:
          # set up the kernel launch parameters
          threadsperblock = (8, 8)
          blocks = ceil(out.shape[0] / threadsperblock[0])
          blockspergrid_x = (
              blocks if blocks < _get_max_gdx() else _get_max_gdx()
          )
  
          blocks = ceil(out.shape[1] / threadsperblock[1])
          blockspergrid_y = (
              blocks if blocks < _get_max_gdy() else _get_max_gdy()
          )
  
          blockspergrid = (blockspergrid_x, blockspergrid_y)
  
          # do computations
          kernel = UPFIRDN_MODULE.get_function(
              f"_cupy_upfirdn2D_{out.dtype.name}"
          )
          kernel(
              threadsperblock,
              blockspergrid,
              (
                  x,
                  x.shape[1],
                  self._h_trans_flip,
                  self._up,
                  self._down,
                  axis,
                  x_shape_a,
                  h_per_phase,
                  padded_len,
                  out,
                  out.shape[0],
                  out.shape[1],
              ),
          )
      else:
          raise NotImplementedError("upfirdn() requires ndim <= 2")
  
      return out
  
file_path: cupy/cupyx/scipy/signal/_upfirdn.py
imports: from math import ceil
  import cupy
label_desc: Use image node_id 2 for calling the _UpFIRDn obj's underlying member method code with example usage: obj.apply_filter(x, axis) and returns: out