skip comparison if input is already a boolean tensor for count_nonzero
For input tensors that are already of `bool` type, the comparison against `0` in `count_nonzero` is superfluous, and actually takes a noticeable amount of time for large inputs, see #60772

Therefore, this PR changes the code to only compare to zero for non-bool inputs. 
`count_nonzeros` is still a very inefficient operation, but I think this is as far as can be improved on the python side.