code: def all_distinct(l, idx):
      
      out = []
      deja_vu = [False for _ in l]
      for i in idx:
          to_add = cp.deepcopy(l[i]) if deja_vu[i] else l[i]
          out.append(to_add)
          deja_vu[i] = True
      return out
docs: Returns the list [l[i] for i in idx] 
      When needed, objects l[i] are replaced by a copy, to make sure that
      the elements of the list are all distinct
  
      Parameters
      ---------
      l: iterable
      idx: iterable that generates ints (e.g. ndarray of ints)
  
      Returns
      -------
      a list