class_docstr: Context manager that when active adds a new name in the hierarcy.
class_docstr_tok: ["Context","manager","that","when","active","adds","a","new","name","in","the","hierarcy","."]
code: def __init__(self, name: str, method_name: str):
      if not name or name[0] == "/":
          raise ValueError("Name scopes must not start with /")
  
      parts = (
          [name]
          if name.startswith(OVERRIDE_PREFIX)
          else name.split("/")
      )
      module = None
      with contextlib.ExitStack() as stack:
          for subname in parts:
              module = NameScopeModule(name=subname)
              stack.enter_context(
                  simulate_module_method(module, method_name)
              )
  
      self.__entered = False
      self.__module = module
      self.__method = method_name
      self.__stack = contextlib.ExitStack()
  
imports: from collections.abc import Mapping
  import contextlib
  import functools
  import inspect
  import re
  from typing import Any, Callable, ContextManager, NamedTuple, Optional, Protocol, TypeVar
  from haiku._src import base
  from haiku._src import config
  from haiku._src import data_structures
  from haiku._src import utils
  import jax
  import jax.numpy
label_desc: Use image node_id 1 to create a new NameScope object  with example: obj = NameScope(name, method_name)