Synchronize() is called, but I have never called that function

When I created a .densenet201pt from Torchvison using Torchscript and ran it on c++, I profiled it with nvprof and found that cudaStreamSyncronize() and cudaDeviceSyncronize() were called.
But I didn’t explicitly call those functions.
Where are these functions called?

These methods might be called internally, e.g. if you transfer device tensors to the CPU, as the GPU would need to be synchronized before the values can be read. This section of the performance guide explains it in a bit more detail.