code: def replace_inplace(directory, search, to_replace) -> None:
      """Traverse the directory and replace search phrase in each file."""
      for root, _, files in os.walk(directory):
          for file_name in files:
              if file_name.endswith(".py"):
                  file_path = os.path.join(root, file_name)
                  with open(file_path, "r", encoding="utf-8") as file:
                      filedata = file.read()
                  if search in filedata:
                      filedata = filedata.replace(search, to_replace)
                      with open(file_path, "w") as file:
                          file.write(filedata)
  
imports: import os
  import shutil
  import sys
label_desc: Use image node_id 4 for calling a global function with example usage: replace_inplace(directory, search, to_replace) without return types