input: 
  from typing import Iterable
  
  def find_mode(values: Iterable[int]) -> int:
      """ Finds the mode (the most frequent number) from a given set of integers.
      If there are multiple modes, it returns the first one encountered.
      >>> find_mode([1, 2, 3, 2, 4, 2])
      2
      >>> find_mode([1, 3, 3, 2, 4, 2])
      3
      """
      max_count = 0
      mode = values[0]
      count = {}
      for item in values:
          if item in count:
              count[item] += 1
          else:
              count[item] = 1
          if count[item] > max_count:
              max_count = count[item]
              mode = item
      return mode
  
output:     max_count = 0
      mode = None
      count = {}
      for item in values:
          if item in count:
              count[item] += 1
          else:
              count[item] = 1
          if count[item] > max_count:
              max_count = count[item]
              mode = item
      return mode