Metadata not routed to transformers in pipeline during cross validation.

### Describe the bug

When using a pipeline with transformers in combination with cross validation, it seems that metadata is not correctly routed to the transformers during prediction. I would expect, that if `set_transform_request` is set, that this is honored when calling predict on the pipeline.

**Edit:** At least according to the code this is a known limitation. Although I couldn't find an issue tracking the progress on this.
https://github.com/scikit-learn/scikit-learn/blob/9028b518e7a906a806a1dc8994f2714cc980c941/sklearn/model_selection/_validation.py#L362C1-L367C14

### Steps/Code to Reproduce

```python
import sklearn
from sklearn.pipeline import Pipeline
from sklearn.linear_model import LinearRegression
from sklearn.datasets import make_regression
from sklearn.base import TransformerMixin, _MetadataRequester
from sklearn.model_selection import cross_validate

print(sklearn.__version__)

sklearn.set_config(enable_metadata_routing=True)


class DummyTransfomerWithMetadata(TransformerMixin, _MetadataRequester):

    def fit(self, X, y=None, metadata=None):
        return self

    def transform(self, X, y=None, metadata=None):
        print(f"Received {metadata=}")
        return X

    # We need to explicitly implement fit_transform,
    # otherwise transform will not receive metadata during fit
    def fit_transform(self, X, y=None, metadata=None):
        return self.transform(X, y, metadata)


X, y = make_regression()

transformer = DummyTransfomerWithMetadata()
transformer.set_fit_request(metadata=True)
transformer.set_transform_request(metadata=True)


pipe = Pipeline([
    ("transformer", transformer),
    ("clf", LinearRegression())
])


print(f"--- Cross validation ---")
cross_validate(
    pipe, X, y, params={"metadata": "Some metadata"}, cv=2
)
```

### Expected Results

```
1.7.0
--- Cross validation ---
Received metadata='Some metadata'   # Fit 
Received metadata='Some metadata'   # Predict
Received metadata='Some metadata'
Received metadata='Some metadata'
```

### Actual Results

```
1.7.0
--- Cross validation ---
Received metadata='Some metadata'
Received metadata=None
Received metadata='Some metadata'
Received metadata=None
```

### Versions

```shell
System:
    python: 3.12.9 (main, Feb 12 2025, 14:50:50) [Clang 19.1.6 ]
executable: /home/max/.cache/uv/archive-v0/unVsgMut5oyZJu14JLk-G/bin/python
   machine: Linux-6.1.138-1-MANJARO-x86_64-with-glibc2.41

Python dependencies:
      sklearn: 1.7.0
          pip: None
   setuptools: None
        numpy: 2.3.1
        scipy: 1.16.0
       Cython: None
       pandas: None
   matplotlib: None
       joblib: 1.5.1
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 12
         prefix: libscipy_openblas
       filepath: /home/max/.cache/uv/archive-v0/unVsgMut5oyZJu14JLk-G/lib/python3.12/site-packages/numpy.libs/libscipy_openblas64_-56d6093b.so
        version: 0.3.29
threading_layer: pthreads
   architecture: Haswell

       user_api: blas
   internal_api: openblas
    num_threads: 12
         prefix: libscipy_openblas
       filepath: /home/max/.cache/uv/archive-v0/unVsgMut5oyZJu14JLk-G/lib/python3.12/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: 12
         prefix: libgomp
       filepath: /home/max/.cache/uv/archive-v0/unVsgMut5oyZJu14JLk-G/lib/python3.12/site-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
        version: None
```

COMMENT:
I worked on a similar bug with the scorer not passing the metadata to the scored estimator in the last two days.
See here for a PR trying to fix this behavior: #31654 

This PR adds passing the metadata to the scored estimator and tries to do the correct routing, which needs to be computed dynamically for each estimator that is scored. It still has some issues with meta-estimators and sample weights.

While it is related, it does not fix directly this issue as  with the proposed PR, I still have the same behavior that `transform` is not provided with the right metadata in your example. I guess this is because the scorer should also require the metadata routing for the `_result_method` of the scored estimator, which makes this more complex...

Labels: Bug, Metadata Routing