Fixing template type check
Adding numpy count_nonzero support