from typing import Counter


def bigram_counts(sequences):
    """Return a dictionary keyed to each unique PAIR of values in the input sequences
    list that counts the number of occurrences of pair in the sequences list. The input
    should be a 2-dimensional array.
    
    For example, if the pair of tags (NOUN, VERB) appear 61582 times, then you should
    return a dictionary such that your_bigram_counts[(NOUN, VERB)] == 61582

    output format:
                    out = {{gram1, gram2}: occurance}
    """
    cnt = Counter()
    for seq in sequences:
        # if len >=2 , then should calculate bigram
        if len(seq) > 1:
            # index against index -1
            for index in range(1, len(seq)):
                bigram = (seq[index - 1], seq[index])
                if bigram not in cnt:
                    cnt[bigram] = 0
                cnt[bigram] += 1
    output = dict(cnt)
    
    return output