You try and call .detach() on something that is already a numpy array as stated in the error.
.detach()