def flatten_tile_conn(tileconn):
    """ Convert tileconn that is key'd to identify specific wire pairs between tiles
  key (tile1_type, wire1_name, tile2_type, wire2_name) to flat tile connect list
  that relates tile types and relative coordinates and a full list of wires to
  connect. """
    flat_tileconn = {}

    for conn in tileconn:
        key = (tuple(conn['tile_types']), tuple(conn['grid_deltas']))

        if key not in flat_tileconn:
            flat_tileconn[key] = {
                'tile_types': conn['tile_types'],
                'grid_deltas': conn['grid_deltas'],
                'wire_pairs': set()
            }

        flat_tileconn[key]['wire_pairs'].add(tuple(conn['wire_pair']))

    def inner():
        for output in flat_tileconn.values():
            yield {
                'tile_types': output['tile_types'],
                'grid_deltas': output['grid_deltas'],
                'wire_pairs': tuple(output['wire_pairs']),
            }

    return tuple(inner())