def has_length(dataset):
    """
    Checks if the dataset implements __len__() and it doesn't raise an error
    """
    try:
        return len(dataset) is not None
    except TypeError:
        # TypeError: len() of unsized object
        return False

    Checks if the dataset implements __len__() and it doesn't raise an error
    
dpkd/transformers/src/transformers/trainer_utils.py