def pattern_loc(start, end, mask, segment_labels):
    """
    Considering that a time series is characterized by regions belonging to two different labels.


    Args:
        start: The starting index of the pattern.
        end: The ending index of the pattern.
        mask: Binary mask used to annotate the time series.
        segment_labels: List of the two labels that characterize the time series.

    Return: The label name of the region that the pattern is contained in.
    """

    if len(segment_labels) != 2:
        raise ValueError('segment_labels must contain exactly 2 labels')

    start = start
    end = end

    # the first label in the list will be assigned to for the True regions in the mask
    true_label = segment_labels[0]

    # the second label in the list will be assigned to for the False regions in the mask
    false_label = segment_labels[1]

    if mask[start] == mask[end]:
        if mask[start] == True:
            loc = true_label
        else:
            loc = false_label
    else:
        # if a pattern spans both regions return the label 'both'
        loc = 'both'

    return loc