code: def clean(document):
      
  
      newdocument = document
  
      # Clean empty text and r tags
      for t in ('t', 'r'):
          rmlist = []
          for element in newdocument.iter():
              if element.tag == '{%s}%s' % (nsprefixes['w'], t):
                  if not element.text and not len(element):
                      rmlist.append(element)
          for element in rmlist:
              element.getparent().remove(element)
  
      return newdocument
docs: Perform misc cleaning operations on documents.
          Returns cleaned document.