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:
@glemaitre thank you that was really insightful for me until now I have only tried to find the workable causes that could cause this please let me know if they are correct


1. The **cross_validation** pipeline distribute **cv**(int) across workers for parallelism and they work upon fit+predict/transform according to the code the :

**Fit object** provides the metadata to the pipeline

But the transform object does not provide it (there may not be explicit code that extends the functionality for providing metadata in scikit methodspace

(Ps: this was my understanding of the code )

Thank you for listening I feel like I am already contributing

Labels: Bug, Metadata Routing