code: def write(module, directory, origin, check=False):
      submodules = [
          (name, member)
          for name, member in inspect.getmembers(module)
          if inspect.ismodule(member)
      ]
  
      filename = os.path.join(directory, "__init__.pyi")
      pyi_content = pyi_file(module)
      pyi_content = do_black(pyi_content, is_pyi=True)
      os.makedirs(directory, exist_ok=True)
      if check:
          with open(filename, "r") as f:
              data = f.read()
              assert (
                  data == pyi_content
              ), f"The content of {filename} seems outdated, please run `python stub.py`"
      else:
          with open(filename, "w") as f:
              f.write(pyi_content)
  
      filename = os.path.join(directory, "__init__.py")
      py_content = py_file(module, origin)
      py_content = do_black(py_content, is_pyi=False)
      os.makedirs(directory, exist_ok=True)
  
      is_auto = False
      if not os.path.exists(filename):
          is_auto = True
      else:
          with open(filename, "r") as f:
              line = f.readline()
              if line == GENERATED_COMMENT:
                  is_auto = True
  
      if is_auto:
          if check:
              with open(filename, "r") as f:
                  data = f.read()
                  assert (
                      data == py_content
                  ), f"The content of {filename} seems outdated, please run `python stub.py`"
          else:
              with open(filename, "w") as f:
                  f.write(py_content)
  
      for name, submodule in submodules:
          write(
              submodule,
              os.path.join(directory, name),
              f"{name}",
              check=check,
          )
  
file_path: safetensors/bindings/python/stub.py
imports: import argparse
  import inspect
  import os
  import black
label_desc: Use image node_id 9 for calling a global function with example usage: write(module, directory, origin, check) without return types