code: def vendor(vendor_dir):
      # remove everything
      delete_all(*vendor_dir.iterdir(), whitelist=WHITELIST)
  
      exclude_subdirs = []
      # Iterate on the vendor*.txt files
      for vendor_file in glob.glob(f"{vendor_dir.name}/vendor*.txt"):
          # We extract the subdirectory we are going to extract into
          subdir = VENDOR_SUBDIR.match(vendor_file).group(1)
          # Includes "any" but it doesn't really matter unless you install "any"
          exclude_subdirs.append(subdir)
  
      for subdir in exclude_subdirs:
          create_init_file = False
          if subdir == "any":
              vendor_subdir = vendor_dir
              # target package is <parent>.<vendor_dir>; foo/_vendor -> foo._vendor
              pkgname = f"{vendor_dir.parent.name}.{vendor_dir.name}"
          else:
              create_init_file = True
              vendor_subdir = vendor_dir / subdir
              # target package is <parent>.<vendor_dir>; foo/_vendor -> foo._vendor
              pkgname = f"{vendor_dir.parent.name}.{vendor_dir.name}.{vendor_subdir.name}"
  
          # install with pip
          subprocess.run(
              [
                  "python3",
                  "-m",
                  "pip",
                  "install",
                  "-t",
                  str(vendor_subdir),
                  "-r",
                  "_vendor/vendor_%s.txt" % subdir,
                  "--no-compile",
              ]
          )
  
          # fetch licenses
          fetch_licenses(
              *vendor_subdir.glob("*.dist-info"),
              vendor_dir=vendor_subdir,
          )
  
          # delete stuff that's not needed
          delete_all(
              *vendor_subdir.glob("*.dist-info"),
              *vendor_subdir.glob("*.egg-info"),
              vendor_subdir / "bin",
          )
  
          # Touch a __init__.py file
          if create_init_file:
              with open(
                  "%s/__init__.py" % str(vendor_subdir),
                  "w+",
                  encoding="utf-8",
              ) as f:
                  f.write("# Empty file")
  
          vendored_libs, paths = find_vendored_libs(
              vendor_subdir, WHITELIST, exclude_subdirs
          )
  
          replacements = []
          for lib in vendored_libs:
              replacements += (
                  partial(  # import bar -> import foo._vendor.bar
                      re.compile(
                          r"(^\s*)import {}\n".format(lib), flags=re.M
                      ).sub,
                      r"\1from {} import {}\n".format(pkgname, lib),
                  ),
                  partial(  # from bar -> from foo._vendor.bar
                      re.compile(
                          r"(^\s*)from {}(\.|\s+)".format(lib),
                          flags=re.M,
                      ).sub,
                      r"\1from {}.{}\2".format(pkgname, lib),
                  ),
              )
  
          for file in chain.from_iterable(map(iter_subtree, paths)):
              if file.suffix == ".py":
                  patch_vendor_imports(file, replacements)
  
file_path: metaflow/metaflow/vendor.py
imports: import glob
  import shutil
  import subprocess
  import re
  from functools import partial
  from itertools import chain
  from pathlib import Path
label_desc: Use image node_id 6 for calling a global function with example usage: vendor(vendor_dir) without return types