def _get_contrastive_sample_type(
    sample: Mapping[str, Any],
) -> ContrastiveSampleType:
    """Get the type of contrastive sample from the sample.

    Args:
        sample (Mapping): A sample from the dataset.

    Returns:
        ContrastiveSampleType: The type of contrastive sample.
    """
    sample_contains_text_a = any(
        key.startswith('text_a') for key in sample.keys()
    )
    sample_contains_text_b = any(
        key.startswith('text_b') for key in sample.keys()
    )

    if sample_contains_text_a and sample_contains_text_b:
        return 'one_query_one_response'
    elif 'query_text' in sample and 'positive_passage' in sample and 'negative_passages' in sample:
        return 'one_query_multiple_responses'
    else:
        raise ValueError(
            'Sample does not contain the required keys for contrastive training. \
                For datasets with one query and one response, the keys must contain \
                "text_a" and "text_b". For datasets with one query and multiple responses, \
                the keys must contain "query_text", "positive_passage", and "negative_passages".',
        )
Get the type of contrastive sample from the sample.

    Args:
        sample (Mapping): A sample from the dataset.

    Returns:
        ContrastiveSampleType: The type of contrastive sample.
    
llmfoundry/data/contrastive_pairs/dataloader.py