code: def _validate_labels(labels):
      
  
      l = len(labels)
      total = 0
      i = -1
      j = 0
      for label in labels:
          ll = len(label)
          total += ll + 1
          if ll > 63:
              raise LabelTooLong
          if i < 0 and label == '':
              i = j
          j += 1
      if total > 255:
          raise NameTooLong
      if i >= 0 and i != l - 1:
          raise EmptyLabel
docs: Check for empty labels in the middle of a label sequence,
      labels that are too long, and for too many labels.
      @raises NameTooLong: the name as a whole is too long
      @raises LabelTooLong: an individual label is too long
      @raises EmptyLabel: a label is empty (i.e. the root label) and appears
      in a position other than the end of the label sequence