code: def name_scope(
      name: str,
      *,
      method_name: str = "__call__",
  ) -> ContextManager[None]:
      """Context manager which adds a prefix to all new modules, params or state.
  
      >>> with hk.name_scope("my_name_scope"):
      ...   net = hk.Linear(1, name="my_linear")
      >>> net.module_name
      'my_name_scope/my_linear'
  
      When used inside a module, any submodules, parameters or state created inside
      the name scope will have a prefix added to their names:
  
      >>> class MyModule(hk.Module):
      ...   def __call__(self, x):
      ...     with hk.name_scope("my_name_scope"):
      ...       submodule = hk.Linear(1, name="submodule")
      ...       w = hk.get_parameter("w", [], init=jnp.ones)
      ...     return submodule(x) + w
  
      >>> f = hk.transform(lambda x: MyModule()(x))
      >>> params = f.init(jax.random.PRNGKey(42), jnp.ones([1, 1]))
      >>> jax.tree_util.tree_map(jnp.shape, params)
      {'my_module/my_name_scope': {'w': ()},
       'my_module/my_name_scope/submodule': {'b': (1,), 'w': (1, 1)}}
  
      Name scopes are very similar to putting all of the code inside the context
      manager inside a method on a :class:`Module` with the name you provide. Behind
      the scenes this is precisely how name scopes are implemented.
  
      If you are familiar with TensorFlow then Haiku's :func:`name_scope` is similar
      to ``tf.variable_scope(..)`` in TensorFlow 1 and ``tf.name_scope(..)`` in
      TensorFlow 1 and 2 in that it changes the names associated with modules,
      parameters and state.
  
      Args:
        name: The name scope to use (e.g. ``"foo"`` or ``"foo/bar"``).
        method_name: (Advanced uses only). Since name scopes are equivalent to
          calling methods on modules the method name attribute allows you to specify
          which method name you want to simulate. Most users should leave this as
          the default value (`"__call__"`).
  
      Returns:
        A single use context manager that when active prefixes new modules,
        parameters or state with the given name.
      """
      base.assert_context("name_scope")
      return NameScope(name, method_name)
  
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 5 for calling a global function with example usage: name_scope(name) and returns: NameScope