code: def sample(records, k, random_seed=None):
      
  
      if random_seed is not None:
          random.seed(random_seed)
  
      result = []
      for i, record in enumerate(records):
          if len(result) < k:
              result.append(record)
          else:
              r = random.randint(0, i)
              if r < k:
                  result[r] = record
      return result
docs: Choose a length-``k`` subset of ``records``, retaining the input
      order.  If k > len(records), all are returned. If an integer
      ``random_seed`` is provided, sets ``random.seed()``