code: def _duplicates(list_):
      
      item_indices = {}
      for i, item in enumerate(list_):
          try:
              item_indices[item].append(i)
          except KeyError:  # First time seen
              item_indices[item] = [i]
      return item_indices
docs: Return dict mapping item -> indices.