code: def patch_doc2path(env, language):
      # patch doc2path so that it resolves to the correct language.
      override_doc2path = env.doc2path
  
      def doc2path(env, docname: str, base: bool = True):
          path = override_doc2path(docname, base)
          if language not in (None, "en"):
              # The language is set to another one
              new_docname = f"{docname}_{language}"
              new_path = override_doc2path(new_docname, base)
              if os.path.exists(new_path):
                  return new_path
          return path
  
      env.doc2path = types.MethodType(doc2path, env)
  
imports: import os
  import types
label_desc: Use image node_id 2 for calling a global function with example usage: patch_doc2path(env, language) and returns: path, new_path