code: def _read_pam_header(self, data):
          
          regroups = re.search(
              b"(^P7[\n\r]+(?:(?:[\n\r]+)|(?:#.*)|"
              b"(HEIGHT\s+\d+)|(WIDTH\s+\d+)|(DEPTH\s+\d+)|(MAXVAL\s+\d+)|"
              b"(?:TUPLTYPE\s+\w+))*ENDHDR\n)", data).groups()
          self.header = regroups[0]
          self.magicnum = b'P7'
          for group in regroups[1:]:
              key, value = group.split()
              setattr(self, unicode(key).lower(), int(value))
          matches = re.findall(b"(TUPLTYPE\s+\w+)", self.header)
          self.tupltypes = [s.split(None, 1)[1] for s in matches]
docs: Read PAM header and initialize instance.