`_check_unknown` returns error for `np.isnan(known_values)` with int64 arrays

### Describe the bug

When `precision_score` is called with two numpy int64 arrays as y_true and y_pred, an error is thrown in the `_check_unknown` function in [sklearn](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn)/[utils](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/utils)/[_encode.py](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/utils/_encode.py). The error states "ufunc 'isnan' not supported for the input types".

### Steps/Code to Reproduce

```
from sklearn.metrics import precision_score
import numpy as np

y_true = np.arange(10)
y_pred = np.arange(10)
np.random.shuffle(y_pred)

precision_score(y_true, y_pred, labels=class_names, average='macro', zero_division=0)
```

### Expected Results

No error is thrown. The precision value is calculated.

### Actual Results


TypeError                                 Traceback (most recent call last)
[<ipython-input-34-c0c8e8c6d0fb>](https://localhost:8080/#) in <module>
      6 np.random.shuffle(y_pred)
      7 
----> 8 precision_score(y_true, y_pred, labels=class_names, average='macro', zero_division=0)

5 frames
[/usr/local/lib/python3.8/dist-packages/sklearn/metrics/_classification.py](https://localhost:8080/#) in precision_score(y_true, y_pred, labels, pos_label, average, sample_weight, zero_division)
   1755     array([0.5, 1. , 1. ])
   1756     """
-> 1757     p, _, _, _ = precision_recall_fscore_support(
   1758         y_true,
   1759         y_pred,

[/usr/local/lib/python3.8/dist-packages/sklearn/metrics/_classification.py](https://localhost:8080/#) in precision_recall_fscore_support(y_true, y_pred, beta, labels, pos_label, average, warn_for, sample_weight, zero_division)
   1546     # Calculate tp_sum, pred_sum, true_sum ###
   1547     samplewise = average == "samples"
-> 1548     MCM = multilabel_confusion_matrix(
   1549         y_true,
   1550         y_pred,

[/usr/local/lib/python3.8/dist-packages/sklearn/metrics/_classification.py](https://localhost:8080/#) in multilabel_confusion_matrix(y_true, y_pred, sample_weight, labels, samplewise)
    504         le = LabelEncoder()
    505         le.fit(labels)
--> 506         y_true = le.transform(y_true)
    507         y_pred = le.transform(y_pred)
    508         sorted_labels = le.classes_

[/usr/local/lib/python3.8/dist-packages/sklearn/preprocessing/_label.py](https://localhost:8080/#) in transform(self, y)
    136             return np.array([])
    137 
--> 138         return _encode(y, uniques=self.classes_)
    139 
    140     def inverse_transform(self, y):

[/usr/local/lib/python3.8/dist-packages/sklearn/utils/_encode.py](https://localhost:8080/#) in _encode(values, uniques, check_unknown)
    185     else:
    186         if check_unknown:
--> 187             diff = _check_unknown(values, uniques)
    188             if diff:
    189                 raise ValueError(f"y contains previously unseen labels: {str(diff)}")

[/usr/local/lib/python3.8/dist-packages/sklearn/utils/_encode.py](https://localhost:8080/#) in _check_unknown(values, known_values, return_mask)
    259 
    260         # check for nans in the known_values
--> 261         if np.isnan(known_values).any():
    262             diff_is_nan = np.isnan(diff)
    263             if diff_is_nan.any():

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

### Versions

```shell
System:
    python: 3.8.10 (default, Nov 14 2022, 12:59:47)  [GCC 9.4.0]
executable: /usr/bin/python3
   machine: Linux-5.10.147+-x86_64-with-glibc2.29

Python dependencies:
          pip: 22.0.4
   setuptools: 57.4.0
      sklearn: 1.0.2
        numpy: 1.21.6
        scipy: 1.7.3
       Cython: 0.29.33
       pandas: 1.3.5
   matplotlib: 3.2.2
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True
```

COMMENT:
Hello,

could you please provide a complete example that reproduces the problem? For the code you provided the variable `class_names` is missing. If I change the last line to `precision_score(y_true, y_pred, average='macro', zero_division=0)` no exception is raised.

Labels: Bug, Needs Triage