def has_len(dataloader: object) -> TypeGuard[Sized]:
    """Checks if a given object has ``__len__`` method implemented."""
    length = sized_len(dataloader)
    if length == 0:
        rank_zero_warn(
            f"`{dataloader.__class__.__name__}` returned 0 length. Please make sure this was your intention."
        )
    if length is not None and has_iterable_dataset(dataloader):
        rank_zero_warn(
            "Your `IterableDataset` has `__len__` defined."
            " In combination with multi-process data loading (when num_workers > 1),"
            " `__len__` could be inaccurate if each worker is not configured independently"
            " to avoid having duplicate data."
        )
    return length is not None
Checks if a given object has ``__len__`` method implemented.
src/lightning/fabric/utilities/data.py