code: def _include(elem, loader, base_url, max_depth, _parent_hrefs):
      # look for xinclude elements
      i = 0
      while i < len(elem):
          e = elem[i]
          if e.tag == XINCLUDE_INCLUDE:
              # process xinclude directive
              href = e.get("href")
              if base_url:
                  href = urljoin(base_url, href)
              parse = e.get("parse", "xml")
              if parse == "xml":
                  if href in _parent_hrefs:
                      raise FatalIncludeError(
                          "recursive include of %s" % href
                      )
                  if max_depth == 0:
                      raise LimitedRecursiveIncludeError(
                          "maximum xinclude depth reached when including file %s"
                          % href
                      )
                  _parent_hrefs.add(href)
                  node = loader(href, parse)
                  if node is None:
                      raise FatalIncludeError(
                          "cannot load %r as %r" % (href, parse)
                      )
                  node = copy.copy(
                      node
                  )  # FIXME: this makes little sense with recursive includes
                  _include(
                      node, loader, href, max_depth - 1, _parent_hrefs
                  )
                  _parent_hrefs.remove(href)
                  if e.tail:
                      node.tail = (node.tail or "") + e.tail
                  elem[i] = node
              elif parse == "text":
                  text = loader(href, parse, e.get("encoding"))
                  if text is None:
                      raise FatalIncludeError(
                          "cannot load %r as %r" % (href, parse)
                      )
                  if e.tail:
                      text += e.tail
                  if i:
                      node = elem[i - 1]
                      node.tail = (node.tail or "") + text
                  else:
                      elem.text = (elem.text or "") + text
                  del elem[i]
                  continue
              else:
                  raise FatalIncludeError(
                      "unknown parse type in xi:include tag (%r)"
                      % parse
                  )
          elif e.tag == XINCLUDE_FALLBACK:
              raise FatalIncludeError(
                  "xi:fallback tag must be child of xi:include (%r)"
                  % e.tag
              )
          else:
              _include(e, loader, base_url, max_depth, _parent_hrefs)
          i += 1
  
file_path: catboost/contrib/tools/python3/src/Lib/xml/etree/ElementInclude.py
imports: import copy
  from .None import ElementTree
  from urllib.parse import urljoin
label_desc: Use image node_id 3 for calling a global function with example usage: _include(elem, loader, base_url, max_depth, _parent_hrefs) without return types