To get the stride, use the stride function: t.stride().
In your original comment, you said that the numpy implementation you provide is what you want. You can implement this exact function in pytorch by using t.size() (to replace a.shape), t.stride() (to replace a.strides) and torch.as_strided() (to replace np.lib.stride_tricks.as_strided()). Then you can use it the same way you would use th numpy version.