Kind of like this:
import torch

N = 1
T = 5
pad = (0,T // 2)
convolution = torch.nn.Conv2d(in_channels=1, out_channels=N, kernel_size=(1, T), padding=pad)

sp = torch.rand(256, 128)

preset_slice = [2*i for i in range(128)]  # Choose your own

harmonics = sp[preset_slice]

processed_harmonics = convolution(harmonics[None,None,...])

new_sp = sp.clone()
new_sp[preset_slice] = processed_harmonics[0,0]

In case of not using convolutions you can handle something similar with fold and unfold I woudl say