Here is the GitHub issue on this topic https://github.com/pytorch/pytorch/issues/2389 148. Apparently, this functionality is not supported at the moment, so we should wait for the feature to be added.