Krishna_Garg:

You mentioned about parameters_to_vector being differentiable. So, how can I check whether a function is differentiable or not?


In general, all ops in pytorch are differentiable.
The main exceptions are .detach() and with torch.no_grad. As well as functions that work with nn.Parameter that needs to remain leafs and so cannot have gradient history.

Also, can you be more specific about the operations in which detach is required

You most likely never need it actually