This error is not attributed to PyTorch. You used reshape in Numpy.
I have a couple of questions. Why did you use 21 instead of 38 when reshaping infile1? Why does the reshaping be necessary for calculating the covariance?