code: def rewrite_file_imports(item, vendored_libs, vendor_dir):
      
      text = item.read_text(encoding='utf-8')
      renames = LIBRARY_RENAMES
      for k in LIBRARY_RENAMES.keys():
          if k not in vendored_libs:
              vendored_libs.append(k)
      for lib in vendored_libs:
          to_lib = lib
          if lib in renames:
              to_lib = renames[lib]
          text = re.sub(
              r'([\n\s]*)import %s([\n\s\.]+)' % lib,
              r'\1import %s\2' % to_lib,
              text,
          )
          text = re.sub(
              r'([\n\s]*)from %s([\s\.])+' % lib,
              r'\1from %s\2' % to_lib,
              text,
          )
          text = re.sub(
              r"(\n\s*)__import__\('%s([\s'\.])+" % lib,
              r"\1__import__('%s\2" % to_lib,
              text,
          )
      item.write_text(text, encoding='utf-8')
docs: Rewrite 'import xxx' and 'from xxx import' for vendored_libs