code: def tobytes(
          self,
          root=None,
          encoding='UTF-8',
          doctype=None,
          canonicalized=True,
          xml_declaration=True,
          pretty_print=True,
          with_comments=True,
      ):
          
          if root is None:
              root = self.root
          if canonicalized == True:
              return self.canonicalized_bytes(root)
          else:
              return etree.tostring(
                  root,
                  encoding=encoding or self.info.encoding,
                  doctype=doctype or self.info.doctype,
                  xml_declaration=xml_declaration,
                  pretty_print=pretty_print,
                  with_comments=with_comments,
              )
docs: return the content of the XML document as a byte string suitable for writing