Please see this comment.
It appears memory_format = torch.channels_last  is not converting the layers/input to NHWC format. It performs a different functionality. Pytorch Channels Last Memory Format 30 webpage also doesn’t mention NHWC anywhere in the whole webpage.
I hope I have put my requirement correctly. Thanks.