def _ret_top_ids(segmented_topics):
 top_ids = set()
 for s_i in segmented_topics:
  for id in chain.from_iterable(s_i):
   if isinstance(id, np.ndarray):
    for i in id:
     top_ids.add(i)
   else:
    top_ids.add(id)
 return top_ids

def _ret_top_ids ( segmented_topics ) : top_ids = set ( ) for s_i in segmented_topics : for id in chain . from_iterable ( s_i ) : if isinstance ( id , np . ndarray ) : for i in id : top_ids . add ( i ) else : top_ids . add ( id ) return top_ids
helper function to return a set of all the unique topic ids in segmented topics .