docs: def encode(locations):
      """
      :param locations: locations list containig (lat, lon) two-tuples
      :return: encoded polyline string
      """
      encoded = (
          (_encode_value(lat, prev_lat), _encode_value(lon, prev_lon))
          for (prev_lat, prev_lon), (lat, lon)
          in _iterate_with_previous(locations, first=(0, 0))
      )
      encoded = chain.from_iterable(encoded)
      return ''.join(c for r in encoded for c in r)