from typing import Sequence
from typing import Any
from typing import Tuple
from typing import Optional


def validate_provided_image_paths(image_paths: Sequence[Any]) -> Tuple[Optional[str], bool]:
    """Given a list of image_paths (list length at least 1), validate them and
    determine if metadata is available.
    Args:
        image_paths: a list of string (image_id) or a list of 2-item lists
            ([image_id, image_metadata])
    Returns:
        error: None if checks passed, otherwise a string error message
        metadata_available: bool, True if available
    """
    # image_paths will have length at least 1, otherwise would have ended before this step
    first_item = image_paths[0]
    metadata_available = False
    if isinstance(first_item, str):
        for i in image_paths:
            if not isinstance(i, str):
                error = 'Not all items in image_paths are of type string.'
                return error, metadata_available
        return None, metadata_available
    elif isinstance(first_item, list):
        metadata_available = True
        for i in image_paths:
            if len(i) != 2:  # i should be [image_id, metadata_string]
                error = ('Items in image_paths are lists, but not all lists '
                         'are of length 2 [image locator, metadata].')
                return error, metadata_available
        return None, metadata_available
    else:
        error = 'image_paths contain items that are not strings nor lists.'
        return error, metadata_available