in arctic_inference/dynasor/entropy.py [0:0]
def majority_voting(answers: List[Any]) -> Any:
"""Find the most common answer using majority voting.
Args:
answers: List of answers to vote on
Returns:
Any: The most common answer
"""
equiv_classes = []
equiv_weights = []
max_vote = 0
for answer in answers:
weight = 1
flag = 0
for i, rep in enumerate(equiv_classes):
if math_equal(answer, rep):
flag = 1
equiv_weights[i] = equiv_weights[i] + weight
if equiv_weights[i] > max_vote:
max_vote = equiv_weights[i]
max_rep = answer
break
if flag:
continue
equiv_classes.append(answer)
equiv_weights.append(weight)
if max_vote == 0:
max_vote = weight
max_rep = answer
return max_rep