Different Python version causes a different distribution of classification result

### Describe the bug

Running the same code using Python 3.10 and Python 3.13 with `n_jobs > 1` had a variety of result. Python 3.10 and Python 3.13 also has different distributions.

### Steps/Code to Reproduce

```python
import numpy as np
import random
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, recall_score, confusion_matrix

# Control the randomness
random.seed(0)  
np.random.seed(0)

iris = load_iris()  
x, y = iris.data, iris.target
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.20, random_state=0)

# Define and create a model
model = RandomForestClassifier(
    n_estimators=np.int64(101),
    criterion='gini',
    max_depth=np.int64(31),
    min_samples_split=7.291122019556396e-304,
    min_samples_leaf=np.int64(14876671),
    min_weight_fraction_leaf=0.0,
    max_features=None,
    max_leaf_nodes=None,
    min_impurity_decrease=0.0,
    bootstrap=True,
    oob_score=False,
    n_jobs= np.int64(255),
    random_state=0,
    verbose=np.int64(0),
    warm_start=False,
    class_weight='balanced_subsample',
    ccp_alpha=0.0,
    max_samples=None)

model.fit(x_train, y_train)

# Evaluate model
y_pred = model.predict(x_test)
print("Accuracy: ", accuracy_score(y_test,
                                    y_pred))
print("Recall:",
    recall_score(y_test, y_pred, average='micro'))
# Print confusion matrix
print("Confusion Matrix:")
print(confusion_matrix(y_test, y_pred))
```

### Expected Results

If `n_jobs` is 1, the result is:
```
    Accuracy:  0.43333333333333335
    Recall: 0.43333333333333335
    Confusion Matrix:
    [[ 0 11  0]
    [ 0 13  0]
    [ 0  6  0]]
```

### Actual Results

When the program is run 10,000 times:
**n_jobs=255, Python 3.10** has two possible results:
```
    Group:
    Accuracy:  0.43333333333333335
    Recall: 0.43333333333333335
    Confusion Matrix:
    [[ 0 11  0]
    [ 0 13  0]
    [ 0  6  0]]
    Count: 9887
    
    Group:
    Accuracy:  0.36666666666666664
    Recall: 0.36666666666666664
    Confusion Matrix:
    [[11  0  0]
    [13  0  0]
    [ 6  0  0]]
    Count: 113
```
**n_jobs=255, Python 3.13** has three possible results:
```
    Group:
    Accuracy:  0.36666666666666664
    Recall: 0.36666666666666664
    Confusion Matrix:
    [[11  0  0]
    [13  0  0]
    [ 6  0  0]]
    Count: 7790
    
    Group:
    Accuracy:  0.43333333333333335
    Recall: 0.43333333333333335
    Confusion Matrix:
    [[ 0 11  0]
    [ 0 13  0]
    [ 0  6  0]]
    Count: 1965
    
    Group:
    Accuracy:  0.2
    Recall: 0.2
    Confusion Matrix:
    [[ 0  0 11]
    [ 0  0 13]
    [ 0  0  6]]
    Count: 245
```

### Versions

```shell
System:
    python: 3.13.2 (main, Mar 27 2025, 14:05:19) [GCC 11.4.0]
executable: /opt/python/3.13.2/bin/python3.13
   machine: Linux-5.15.0-122-generic-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.6.1
          pip: 24.3.1
   setuptools: 75.6.0
        numpy: 2.2.4
        scipy: 1.15.2
       Cython: None
       pandas: 2.2.3
   matplotlib: None
       joblib: 1.4.2
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libscipy_openblas
       filepath: /users/GloC99/.local/lib/python3.13/site-packages/numpy.libs/libscipy_openblas64_-6bb31eeb.so
        version: 0.3.28
threading_layer: pthreads
   architecture: Haswell

       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libscipy_openblas
       filepath: /users/GloC99/.local/lib/python3.13/site-packages/scipy.libs/libscipy_openblas-68440149.so
        version: 0.3.28
threading_layer: pthreads
   architecture: Haswell

       user_api: openmp
   internal_api: openmp
    num_threads: 16
         prefix: libgomp
       filepath: /users/GloC99/.local/lib/python3.13/site-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
        version: None

===============

System:
    python: 3.10.17 (main, Apr 10 2025, 12:04:30) [GCC 11.4.0]
executable: /opt/python/3.10.17/bin/python3.10
   machine: Linux-5.15.0-122-generic-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.6.1
          pip: 24.3.1
   setuptools: 75.6.0
        numpy: 2.2.0
        scipy: 1.14.1
       Cython: None
       pandas: 2.2.3
   matplotlib: None
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libscipy_openblas
       filepath: /users/GloC99/.local/lib/python3.10/site-packages/numpy.libs/libscipy_openblas64_-6bb31eeb.so
        version: 0.3.28
threading_layer: pthreads
   architecture: Haswell

       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libscipy_openblas
       filepath: /users/GloC99/.local/lib/python3.10/site-packages/scipy.libs/libscipy_openblas-c128ec02.so
        version: 0.3.27.dev
threading_layer: pthreads
   architecture: Haswell

       user_api: openmp
   internal_api: openmp
    num_threads: 16
         prefix: libgomp
       filepath: /users/GloC99/.local/lib/python3.10/site-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
        version: None
```

COMMENT:
> i didnt understand what exactly i have to do??

@GAVARA-PRABHAS-RAM First, we need to analyze the root cause of the behavior reported by @GloC99 and assess whether this is a bug or not.

@GloC99 thanks for the report. I confirm I can reproduce locally with a fresh conda-forge based environment running Python 3.13 on macOS. But, strangely, I could not reproduce using my usual dev env running Python 3.12 and scikit-learn `main` built from source.

Some preliminary remarks:

- fitting with `n_jobs=255` on a machine with 16 cores is likely to be either useless or even detrimental from a performance point of view.

- fitting `min_samples_leaf=np.int64(14876671)` on the 150 data points of the iris dataset means that the trees will never perform any split and the single leaf will consistently predict the marginal class frequencies observed on the (bootstrapped) training sets. This can be checked via:

```python
>>> np.unique([e.tree_.node_count for e in model.estimators_])
array([1])
```

I will try to investigate a bit further to understand the source of the non-deterministic behavior now that I can reproduce.

Labels: Bug