For the other issue of not learning, the problem is that your functions is not differentiable wrt to the shift as you use it. Here you use it as an integer index. So pytorch cannot compute gradient for it.
What kind of gradients were you expecting here?
For the absence of warning/error, it might be because your run an old version of pytorch? I ran the code from the latest nightly build.