Refer to the following link code https://github.com/K1T00/DeepLearningSegmentationEditor/blob/master/NativeTorchCudaOps/TORCHSHARP_CUDA_EMPTY_CACHE_WINDOWS.md