code: def clean(path: str, patch: str) -> None:
      with open(path, "r") as f:
          spec = json.load(f)
  
      keys_to_rename: List[str] = []
      for key, value in spec["definitions"].items():
          # Remove definitions that should be hidden from the user.
          if key == "protobufAny":
              value["title"] = "Object"
          elif key == "protobufNullValue":
              value["title"] = "NullValue"
  
          # Clean up titles. Title is used in documentation.
          if "title" not in value:
              value["title"] = "".join(
                  capitalize(k) for k in key.split(sep="v1")
              )
          elif value["title"].startswith(SERVICE_NAME):
              value["title"] = value["title"][
                  len(SERVICE_NAME) :
              ].lstrip()
              value["title"] = capitalize(value["title"])
  
          if "required" in value:
              value["required"] = [
                  to_lower_camel_case(attr)
                  for attr in value["required"]
              ]
  
          if key.startswith(SERVICE_NAME.lower()):
              keys_to_rename.append(key)
  
      for key in keys_to_rename:
          spec["definitions"][key[len(SERVICE_NAME) :]] = spec[
              "definitions"
          ].pop(key)
  
      # recursively find any objects with ref to keys_to_rename and rename them
      def rename_refs(obj: Any):
          if isinstance(obj, dict):
              for k, v in obj.items():
                  if k == "$ref":
                      for key in keys_to_rename:
                          if v.endswith(key):
                              obj[k] = v.replace(
                                  key, key[len(SERVICE_NAME) :]
                              )
                  else:
                      rename_refs(v)
          elif isinstance(obj, list):
              for v in obj:
                  rename_refs(v)
  
      rename_refs(spec)
  
      # remove operationId prefix from the main service.
      operationid_prefix = SERVICE_NAME + "_"
      for url, value in spec["paths"].items():
          for method, api in value.items():
              cur_id = str(api["operationId"])
              if cur_id.startswith(operationid_prefix):
                  spec["paths"][url][method]["operationId"] = cur_id[
                      len(operationid_prefix) :
                  ]
  
      with open(patch, "r") as f:
          merge_dict(spec, json.load(f))
  
      with open(path, "w") as f:
          json.dump(spec, f)
  
imports: import json
  import sys
  from typing import Any, Dict, List
label_desc: Use image node_id 4 for calling a global function with example usage: clean(path, patch) without return types