code: def write_keys(self, records_in, clean=True):
          
  
          if isinstance(records_in, FITSHDR):
              hdr = records_in
          else:
              hdr = FITSHDR(records_in)
  
          if clean:
              is_table = hasattr(self, '_table_type_str')
              # is_table = isinstance(self, TableHDU)
              hdr.clean(is_table=is_table)
  
          for r in hdr.records():
              name = r['name'].upper()
              value = r['value']
  
              if name == 'COMMENT':
                  self.write_comment(value)
              elif name == 'HISTORY':
                  self.write_history(value)
              elif name == 'CONTINUE':
                  self._write_continue(value)
              else:
                  comment = r.get('comment', '')
                  self.write_key(name, value, comment=comment)
docs: Write the keywords to the header.
  
          parameters
          ----------
          records: FITSHDR or list or dict
              Can be one of these:
                  - FITSHDR object
                  - list of dictionaries containing 'name','value' and optionally
                    a 'comment' field; the order is preserved.
                  - a dictionary of keyword-value pairs; no comments are written
                    in this case, and the order is arbitrary.
          clean: boolean
              If True, trim out the standard fits header keywords that are
              created on HDU creation, such as EXTEND, SIMPLE, STTYPE, TFORM,
              TDIM, XTENSION, BITPIX, NAXIS, etc.
  
          Notes
          -----
          Input keys named COMMENT and HISTORY are written using the
          write_comment and write_history methods.