code: def _check_for_duplicates(xs, attr, check_fn=None):
      
      dups = []
      for key, vals in itertools.groupby(x[attr] for x in xs):
          if len(list(vals)) > 1:
              dups.append(key)
      if len(dups) > 0:
          psamples = []
          for x in xs:
              if x[attr] in dups:
                  psamples.append(x)
          # option to skip problem based on custom input function.
          if check_fn and check_fn(psamples):
              return
          descrs = [x["description"] for x in psamples]
          raise ValueError("Duplicate '%s' found in input sample configuration.\n"
                           "Required to be unique for a project: %s\n"
                           "Problem found in these samples: %s" % (attr, dups, descrs))
docs: Identify and raise errors on duplicate items.