IBM watsonx.ai preprocessing pipelines may need lightweight signal transformations before model inference. Implement a valid one-dimensional convolution without using numerical libraries.
Given a non-empty numeric signal and a non-empty numeric kernel, return their valid convolution. Valid convolution uses no padding and includes only positions where the entire kernel overlaps the signal. The kernel must be reversed before multiplication, so the result at position i is:
output[i] = sum(signal[i + j] * kernel[m - 1 - j] for j in range(m)), where m = len(kernel).
signal, a list of integers or floating-point values, and kernel, another such list.len(signal) - len(kernel) + 1.def valid_convolution(signal, kernel):