code: def check_levels(imls, imt, min_iml=1E-10):
      if len(imls) < 1:
          raise ValueError('No imls for %s: %s' % (imt, imls))
      elif imls != sorted(imls):
          raise ValueError('The imls for %s are not sorted: %s' % (imt, imls))
      elif len(distinct(imls)) < len(imls):
          raise ValueError("Found duplicated levels for %s: %s" % (imt, imls))
      elif imls[0] == 0 and imls[1] <= min_iml:
          raise ValueError("The min_iml %s=%s is larger than the second level "
                           "for %s" % (imt, min_iml, imls))
      elif imls[0] == 0 and imls[1] > min_iml:
          imls[0] = min_iml