def to_sample(input: Any) -> Dict[str, Any]:
    """Cast a single input to a sample dictionary. Uses the following rules:

    * If the input is a dictionary with an "input" key, it will be returned
    * If the input is list-like and of length 2 then the first element will be treated as the input and the second
        element will be treated as the target
    * Else the whole input will be mapped by the input key in the returned sample

    Args:
        input: The input to cast to a sample.

    Returns:
        A sample dictionary.

    """
    if isinstance(input, dict) and DataKeys.INPUT in input:
        return input
    if _is_list_like(input) and len(input) == 2:
        if input[1] is not None:
            return {DataKeys.INPUT: input[0], DataKeys.TARGET: input[1]}
        input = input[0]
    return {DataKeys.INPUT: input}
Cast a single input to a sample dictionary. Uses the following rules:

    * If the input is a dictionary with an "input" key, it will be returned
    * If the input is list-like and of length 2 then the first element will be treated as the input and the second
        element will be treated as the target
    * Else the whole input will be mapped by the input key in the returned sample

    Args:
        input: The input to cast to a sample.

    Returns:
        A sample dictionary.

    
src/flash/core/data/utilities/samples.py