class_docstr: The primary configuration parser. It traverses a structured config (in the form of nested Python dict or list),
  creates ``ConfigItem``, and assign unique IDs according to the structures.
  
  This class provides convenient access to the set of ``ConfigItem`` of the config by ID.
  A typical workflow of config parsing is as follows:
  
      - Initialize ``ConfigParser`` with the ``config`` source.
      - Call ``get_parsed_content()`` to get expected component with `id`.
  
  .. code-block:: python
  
      from monai.bundle import ConfigParser
  
      config = {
          "my_dims": 2,
          "dims_1": "$@my_dims + 1",
          "my_xform": {"_target_": "LoadImage"},
          "my_net": {"_target_": "BasicUNet", "spatial_dims": "@dims_1", "in_channels": 1, "out_channels": 4},
          "trainer": {"_target_": "SupervisedTrainer", "network": "@my_net", "preprocessing": "@my_xform"}
      }
      # in the example $@my_dims + 1 is an expression, which adds 1 to the value of @my_dims
      parser = ConfigParser(config)
  
      # get/set configuration content, the set method should happen before calling parse()
      print(parser["my_net"]["in_channels"])  # original input channels 1
      parser["my_net"]["in_channels"] = 4  # change input channels to 4
      print(parser["my_net"]["in_channels"])
  
      # instantiate the network component
      parser.parse(True)
      net = parser.get_parsed_content("my_net", instantiate=True)
      print(net)
  
      # also support to get the configuration content of parsed `ConfigItem`
      trainer = parser.get_parsed_content("trainer", instantiate=False)
      print(trainer)
  
  Args:
      config: input config source to parse.
      excludes: when importing modules to instantiate components,
          excluding components from modules specified in ``excludes``.
      globals: pre-import packages as global variables to ``ConfigExpression``,
          so that expressions, for example, ``"$monai.data.list_data_collate"`` can use ``monai`` modules.
          The current supported globals and alias names are
          ``{"monai": "monai", "torch": "torch", "np": "numpy", "numpy": "numpy"}``.
          These are MONAI's minimal dependencies. Additional packages could be included with `globals={"itk": "itk"}`.
          Set it to ``False`` to disable `self.globals` module importing.
  
  See also:
  
      - :py:class:`monai.bundle.ConfigItem`
      - :py:class:`monai.bundle.scripts.run`
class_docstr_tok: ["The","primary","configuration","parser",".","It","traverses","a","structured","config","(","in","the","form","of","nested","Python","dict","or","list",")",",","creates","``","ConfigItem","``",",","and","assign","unique","IDs","according","to","the","structures",".","This","class","provides","convenient","access","to","the","set","of","``","ConfigItem","``","of","the","config","by","ID",".","A","typical","workflow","of","config","parsing","is","as","follows",":","-","Initialize","``","ConfigParser","``","with","the","``","config","``","source",".","-","Call","``","get_parsed_content","(",")","``","to","get","expected","component","with","`","id","`",".","..","code-block",":",":","python","from","monai.bundle","import","ConfigParser","config","=","{","``","my_dims","''",":","2",",","``","dims_1","''",":","``","$","@","my_dims","+","1","''",",","``","my_xform","''",":","{","``","_target_","''",":","``","LoadImage","''","}",",","``","my_net","''",":","{","``","_target_","''",":","``","BasicUNet","''",",","``","spatial_dims","''",":","``","@","dims_1","''",",","``","in_channels","''",":","1",",","``","out_channels","''",":","4","}",",","``","trainer","''",":","{","``","_target_","''",":","``","SupervisedTrainer","''",",","``","network","''",":","``","@","my_net","''",",","``","preprocessing","''",":","``","@","my_xform","''","}","}","#","in","the","example","$","@","my_dims","+","1","is","an","expression",",","which","adds","1","to","the","value","of","@","my_dims","parser","=","ConfigParser","(","config",")","#","get\/set","configuration","content",",","the","set","method","should","happen","before","calling","parse","(",")","print","(","parser","[","``","my_net","''","]","[","``","in_channels","''","]",")","#","original","input","channels","1","parser","[","``","my_net","''","]","[","``","in_channels","''","]","=","4","#","change","input","channels","to","4","print","(","parser","[","``","my_net","''","]","[","``","in_channels","''","]",")","#","instantiate","the","network","component","parser.parse","(","True",")","net","=","parser.get_parsed_content","(","``","my_net","''",",","instantiate=True",")","print","(","net",")","#","also","support","to","get","the","configuration","content","of","parsed","`","ConfigItem","`","trainer","=","parser.get_parsed_content","(","``","trainer","''",",","instantiate=False",")","print","(","trainer",")","Args",":","config",":","input","config","source","to","parse",".","excludes",":","when","importing","modules","to","instantiate","components",",","excluding","components","from","modules","specified","in","``","excludes","``",".","globals",":","pre-import","packages","as","global","variables","to","``","ConfigExpression","``",",","so","that","expressions",",","for","example",",","``","``","$","monai.data.list_data_collate","''","``","can","use","``","monai","``","modules",".","The","current","supported","globals","and","alias","names","are","``","{","``","monai","''",":","``","monai","''",",","``","torch","''",":","``","torch","''",",","``","np","''",":","``","numpy","''",",","``","numpy","''",":","``","numpy","''","}","``",".","These","are","MONAI","'s","minimal","dependencies",".","Additional","packages","could","be","included","with","`","globals=","{","``","itk","''",":","``","itk","''","}","`",".","Set","it","to","``","False","``","to","disable","`","self.globals","`","module","importing",".","See","also",":","-",":","py",":","class",":","`","monai.bundle.ConfigItem","`","-",":","py",":","class",":","`","monai.bundle.scripts.run","`"]
docstr: Returns True if `id` is stored in this configuration.
  
  Args:
      id: id to specify the expected position. See also :py:meth:`__getitem__`.
docstr_tok: ["Returns","True","if","`","id","`","is","stored","in","this","configuration",".","Args",":","id",":","id","to","specify","the","expected","position",".","See","also",":","py",":","meth",":","`","__getitem__","`","."]
code: def __contains__(self, id: str | int) -> bool:
      """
      Returns True if `id` is stored in this configuration.
  
      Args:
          id: id to specify the expected position. See also :py:meth:`__getitem__`.
      """
      try:
          _ = self[id]
          return True
      except (
          KeyError,
          IndexError,
          ValueError,
      ):  # Index error for integer indexing
          return False
  
imports: from __future__ import annotations
  import json
  import re
  from collections.abc import Sequence
  from copy import deepcopy
  from pathlib import Path
  from typing import TYPE_CHECKING, Any
  from monai.bundle.config_item import ComponentLocator, ConfigComponent, ConfigExpression, ConfigItem
  from monai.bundle.reference_resolver import ReferenceResolver
  from monai.bundle.utils import ID_REF_KEY, ID_SEP_KEY, MACRO_KEY
  from monai.config import PathLike
  from monai.utils import ensure_tuple, look_up_option, optional_import
  from monai.utils.misc import CheckKeyDuplicatesYamlLoader, check_key_duplicates
label_desc: Use image node_id 9 for calling the ConfigParser obj's underlying member method code with example usage: obj.__contains__(id) and returns: True, False