import collections
import operator


def is_batch_good(batch):
    """
    Checks if a batch of tokens is valid.

    Parameters
    ----------
    batch : list
        A list of integer tokens
    """
    my_dict = collections.defaultdict(int)
  
    for i in batch:
        my_dict[i] += 1
  
    sorted_x = sorted(my_dict.items(), key=operator.itemgetter(1), reverse=True)
    n = len(batch)

    if float(sorted_x[0][1]) / float(n) < 0.5:
        return True
    return False