Exception on rendering html empty pipeline

### Describe the bug

Rendering empty pipeline to html fails, and just simply displaying an empty pipeline fails on IPython/Jupyter.

See upstream IPython issue:

https://github.com/ipython/ipython/issues/14568

### Steps/Code to Reproduce

```python
>>> from sklearn.pipeline import Pipeline
>>> pipeline = Pipeline(steps=[])
>>> pipeline
Pipeline(steps=[])
>>> from sklearn.utils._estimator_html_repr import estimator_html_repr
>>> estimator_html_repr(pipeline)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/_estimator_html_repr.py", line 348, in estimator_html_repr
    check_is_fitted(estimator)
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/validation.py", line 1660, in check_is_fitted
    if not _is_fitted(estimator, attributes, all_or_any):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/validation.py", line 1579, in _is_fitted
    return estimator.__sklearn_is_fitted__()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/pipeline.py", line 1096, in __sklearn_is_fitted__
    check_is_fitted(self.steps[-1][1])
                    ~~~~~~~~~~^^^^
IndexError: list index out of range
```

or just in IPython:

```python
# This code fails - EMPTY pipeline is rendered

from sklearn.pipeline import Pipeline

# Create pipeline
pipeline = Pipeline(steps=[])
pipeline
# same error, no need to explicitely call the repr code as it is registerd.
```

### Expected Results

Don't raise in the repr_handler.


### Actual Results

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/_estimator_html_repr.py", line 348, in estimator_html_repr
    check_is_fitted(estimator)
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/validation.py", line 1660, in check_is_fitted
    if not _is_fitted(estimator, attributes, all_or_any):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/utils/validation.py", line 1579, in _is_fitted
    return estimator.__sklearn_is_fitted__()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniconda3/envs/arm64/lib/python3.12/site-packages/sklearn/pipeline.py", line 1096, in __sklearn_is_fitted__
    check_is_fitted(self.steps[-1][1])
                    ~~~~~~~~~~^^^^
IndexError: list index out of range
```

### Versions

```shell
sklearn: 1.5.2
```

COMMENT:
It looks like there is two fixes to be done:

- raise a more informative error in case of an empty `Pipeline` instead of the "out of range" error.
- make the `__repr__` more lenient to this error.

The second item would depend on how we handle the first one.

Thanks @Carreau bringing this upstream.

Labels: Bug