What is CUDA GUARD?

I found ‘CUDA GUARD’

but I don’t know exactly what is cuda guard and when it’s necessary.

Assuming you are referring to the CUDAGuard guard(device_index_); used in the backend: it’s used to set the specified device in the scope and reset it afterwards.