As @albanD explained, if you install the PyTorch binaries with cudatoolkit, your local CUDA installation won’t be used, but instead the one shipped with the binaries.
If I understand the original question right, you would like to install PyTorch with CUDA10.1 as the binaries, while CUDA10.2 is installed locally on your machine?
If that’s the case, then yes it’ll work as the binaries won’t interfere with the local installation.