code: def vote_IRV(candidates, votes, n_winners):
      
      # TODO: Check what is wrong in here.
      votes = [[e[0] for e in v] for v in votes]
      f = lambda x: Counter(e[0] for e in x).most_common()
      cl = list(candidates)
      ranking = []
      fp = f(votes)
      fpl = [e[0] for e in fp]
  
      while len(fpl) > 1:
          _remove_zeros(votes, fpl, cl, ranking)
          _remove_last(votes, fpl, cl, ranking)
          cl = fpl[:-1]
          fp = f(votes)
          fpl = [e[0] for e in fp]
  
      ranking.append((fpl[0], len(ranking) + 1))
      ranking = list(reversed(ranking))
      return ranking[:min(n_winners, len(ranking))]
docs: Perform IRV voting based on votes.
  
      Ties are resolved randomly.
  
      :param candidates: All candidates in the vote
      :param votes: Votes from the agents
      :param int n_winners: The number of vote winners