Appreciate for your reply. But you did misunderstand my question.
I hope B to be a filter, do torch.mean(slice_A - B), and slide B to next position, etc. And the result would has shape (b, c, A.shape[-1] - B.shape[-1] + 1,  A.shape[-1] - B.shape[-1] + 1).