Hi,
not sure if you’re still looking for a solution, but I have recently written a small package named unfoldNd 19 that should do what you want.
unfoldNd.UnfoldNd works exactly like torch.nn.Unfold, also for 5d inputs. Here 16 is a small demo.
Hope it’s useful.