How to train mobilenet and mnasnet with my n-pair-angular loss?

I am trying to train torchvisions (0.4.0) mobilenet and mnasnet with n-pair-angular loss function. But I am getting error which is probably related to inplace=True

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [20, 1280, 7, 7]], which is output 0 of HardtanhBackward1, is at version 2; expected version 1 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient.

Error at : result = torch._C.nn.hardtanh(input, min_val, max_val)

Training works for other models from torchvision models, but I am stuck with those two models.
Is it possible to make it work? Does changing inplace=True to False change the function of the model itself?