code: def tally_poll(args):
      if not args.msg:
          return "Syntax: !vote tally <pollnum>"
      if not args.msg.isdigit():
          return "Not A Valid Positive Integer."
      pid = int(args.msg)
      poll = get_open_poll(args.session, pid)
      if poll is None:
          return "That poll doesn't exist or was deleted. Use !poll list to see valid polls"
      state = "Active" if poll.active == 1 else "Closed"
      votes = args.session.query(Poll_responses).filter(Poll_responses.pid == pid).all()
      args.send("%s poll: %s, %d total votes" % (state, poll.question, len(votes)))
      votemap = collections.defaultdict(list)
      for v in votes:
          votemap[v.response].append(v.voter)
      for x in sorted(votemap.keys()):
          args.send("%s: %d -- %s" % (x, len(votemap[x]), ", ".join(votemap[x])), target=args.nick)
      if not votemap:
          return ""
      ranking = collections.defaultdict(list)
      for x in votemap.keys():
          num = len(votemap[x])
          ranking[num].append(x)
      high = max(ranking)
      winners = (ranking[high], high)
      if len(winners[0]) == 1:
          winners = (winners[0][0], high)
          return "The winner is %s with %d votes." % winners
      else:
          winners = (", ".join(winners[0]), high)
          return "Tie between %s with %d votes." % winners