`_MultimetricScorer` deals with `_accept_sample_weights` inconsistently

### Describe the bug

When one of the scorers in `_MultimetricScorer` is not a `Scorer` object, it is handled incorrectly.

See line [here](https://github.com/scikit-learn/scikit-learn/blob/0fc081a4e131b08cb6d22f77f250733f265097b4/sklearn/metrics/_scorer.py#L143). If the scorers passed to `MultimetricScorer` are of the following type: [`Scorer`, `function`], it raises an error because the attribute `_accept_sample_weight` does not exist for the second scorer (`function` in this case). This (possibly) bug is present only in 1.7.0 since before this, the `sample_weight` kwarg was being passed to all functions without a check of accepting sample weights.

Possible fix: Use `if hasattr(scorer, '_accept_sample_weight'`) or `if isinstance(scorer, _BaseScorer)` _before_ checking for the `_accept_sample_weight` attribute.

### Steps/Code to Reproduce

```python
import numpy as np
from sklearn.base import BaseEstimator, RegressorMixin
from sklearn.metrics._scorer import _BaseScorer, _MultimetricScorer

# Step 1: Define a simple estimator
class SimpleEstimator(BaseEstimator, RegressorMixin):
    def fit(self, X, y):
        self.mean_ = np.mean(y)
        return self

    def predict(self, X):
        return np.full(X.shape[0], self.mean_)

# Step 2: Define a custom scorer inheriting from _BaseScorer and a function which estimates score
class SimpleScorer(_BaseScorer):
    def _score(self, method_caller, estimator, X, y_true, sample_weight=None):
        y_pred = method_caller(estimator, "predict", X)
        return self._score_func(y_true, y_pred, **self._kwargs)

def default_score(estimator, X, y, sample_weight=None, **kws):
    return estimator.score(X, y, sample_weight=sample_weight)

def mse(y, y_pred):
    return np.mean((y - y_pred)**2)

# Step 3: Create a _MultimetricScorer with multiple scorers
scorers = {
    "mse": SimpleScorer(mse, sign=1, kwargs={}),
    "default": default_score
}
multi_scorer = _MultimetricScorer(scorers=scorers)

# Step 4: Generate sample data
X = np.random.rand(10, 2)
y = np.random.rand(10)
sample_weight = np.random.rand(10)

# Step 5: Fit the estimator and evaluate using the multi-scorer
estimator = SimpleEstimator()
estimator.fit(X, y)
scores = multi_scorer(estimator, X, y, sample_weight=sample_weight)

print("Scores:", scores)
```

### Expected Results

Expected result would be scores for each of the scorers without an error being raised.

### Actual Results

```
AttributeError                            Traceback (most recent call last)
Cell In[6], line 4
      2 estimator = SimpleEstimator()
      3 estimator.fit(X, y)
----> 4 scores = multi_scorer(estimator, X, y, sample_weight=sample_weight)
      6 print("Scores:", scores)

File ~/anaconda3/envs/scoring-311-2/lib/python3.11/site-packages/sklearn/metrics/_scorer.py:144, in _MultimetricScorer.__call__(self, estimator, *args, **kwargs)
    142     if "sample_weight" in kwargs:
    143         for name, scorer in self._scorers.items():
--> 144             if scorer._accept_sample_weight():
    145                 routed_params[name].score["sample_weight"] = kwargs[
    146                     "sample_weight"
    147                 ]
    149 for name, scorer in self._scorers.items():

AttributeError: 'function' object has no attribute '_accept_sample_weight'
```

### Versions

```shell
The `***` below is to obscure some personal details.


System:
    python: 3.11.13 | packaged by conda-forge | (main, Jun  4 2025, 14:52:34) [Clang 18.1.8 ]
executable: /Users/***/anaconda3/envs/***/bin/python3.11
   machine: macOS-15.5-arm64-arm-64bit

Python dependencies:
      sklearn: 1.7.0
          pip: 25.1.1
   setuptools: 80.9.0
        numpy: 2.2.6
        scipy: 1.15.2
       Cython: None
       pandas: 2.3.0
   matplotlib: None
       joblib: 1.5.1
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 14
         prefix: libopenblas
       filepath: /Users/***/anaconda3/envs/***/lib/libopenblas.0.dylib
        version: 0.3.29
threading_layer: openmp
   architecture: VORTEX

       user_api: openmp
   internal_api: openmp
    num_threads: 14
         prefix: libomp
       filepath: /Users/***/anaconda3/envs/***/lib/libomp.dylib
        version: None
```

COMMENT:
Thanks for the issue, I confirm that I can reproduce the behaviour of your snippet. It fails on 1.7 and seems to work fine on 1.6.2.

So I looked a little bit at it and I have only managed to get more confused. Now I am not sure whether this is supposed to work at all ... 

I am looking at the [Using multiple metric evaluation doc](https://scikit-learn.org/stable/modules/model_evaluation.html#using-multiple-metric-evaluation) which is not crystal clear about it.

Here is a way to reproduce with `GridSearchCV` that seems to have a similar behaviour [^1]

```py
import numpy as np
from sklearn.metrics import make_scorer, mean_squared_error
from sklearn.linear_model import Ridge
from sklearn.model_selection import GridSearchCV

def score_func(estimator, X, y, sample_weight=None, **kws):
    return 1

scorers = {
    "mse": make_scorer(mean_squared_error, greater_is_better=False),
    "default": score_func
}

rng = np.random.RandomState(0)
X = rng.rand(10, 2)
y = rng.rand(10)
sample_weight = rng.rand(10)

gs = GridSearchCV(Ridge(), scoring=scorers, param_grid={'alpha': [0.1, 1, 10]}, refit=False)
gs.fit(X, y, sample_weight=sample_weight)
```

<details>
<summary>Traceback</summary>

```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File /tmp/test.py:20
     17 sample_weight = rng.rand(10)
     19 gs = GridSearchCV(Ridge(), scoring=scorers, param_grid={'alpha': [0.1, 1, 10]}, refit=False)
---> 20 gs.fit(X, y, sample_weight=sample_weight)

File ~/dev/scikit-learn/sklearn/base.py:1365, in _fit_context.<locals>.decorator.<locals>.wrapper(estimator, *args, **kwargs)
   1358     estimator._validate_params()
   1360 with config_context(
   1361     skip_parameter_validation=(
   1362         prefer_skip_nested_validation or global_skip_validation
   1363     )
   1364 ):
-> 1365     return fit_method(estimator, *args, **kwargs)

File ~/dev/scikit-learn/sklearn/model_selection/_search.py:964, in BaseSearchCV.fit(self, X, y, **params)
    961 X, y = indexable(X, y)
    962 params = _check_method_params(X, params=params)
--> 964 routed_params = self._get_routed_params_for_fit(params)
    966 cv_orig = check_cv(self.cv, y, classifier=is_classifier(estimator))
    967 n_splits = cv_orig.get_n_splits(X, y, **routed_params.splitter.split)

File ~/dev/scikit-learn/sklearn/model_selection/_search.py:915, in BaseSearchCV._get_routed_params_for_fit(self, params)
    905     routed_params = Bunch(
    906         estimator=Bunch(fit=params),
    907         splitter=Bunch(split={"groups": groups}),
    908         scorer=Bunch(score={}),
    909     )
    910     # NOTE: sample_weight is forwarded to the scorer if sample_weight
    911     # is not None and scorers accept sample_weight. For _MultimetricScorer,
    912     # sample_weight is forwarded if any scorer accepts sample_weight
    913     if (
    914         params.get("sample_weight") is not None
--> 915         and self._check_scorers_accept_sample_weight()
    916     ):
    917         routed_params.scorer.score["sample_weight"] = params["sample_weight"]
    918 return routed_params

File ~/dev/scikit-learn/sklearn/model_selection/_search.py:873, in BaseSearchCV._check_scorers_accept_sample_weight(self)
    871 if isinstance(scorers, _MultimetricScorer):
    872     for name, scorer in scorers._scorers.items():
--> 873         if not scorer._accept_sample_weight():
    874             warnings.warn(
    875                 f"The scoring {name}={scorer} does not support sample_weight, "
    876                 "which may lead to statistically incorrect results when "
    877                 f"fitting {self} with sample_weight. "
    878             )
    879     return scorers._accept_sample_weight()

AttributeError: 'function' object has no attribute '_accept_sample_weight'
```

</details>

[^1]: I wanted to make sure this change affected public classes and not only private classes like `_MultimetricScorer`.

Labels: Bug, module:metrics, Needs Investigation