It seems PyTorch unfold and as_stride are doing the same thing but for the former, you cannot control the tensor output size.
unfold
as_stride