code: def wrap_with_name_scope(
      method: Callable[..., T],
      instance: Any,
      args: Sequence[Any],
      kwargs: Dict[str, Any],
  ) -> T:
      """Decorator that calls the given function in the module name scope.
  
      Args:
        method: The bound method to call.
        instance: `Module` instance.
        args: Positional arguments to `method`.
        kwargs: Keyword arguments to `method`.
  
      Returns:
        `with instance.name_scope: return method(*args, **kwargs)`
      """
      if instance is None:
          instance = args[0]
          args = args[1:]
          method = functools.partial(method, instance)
  
      try:
          module_name_scope = instance.name_scope
      except AttributeError as exc_value_from:
          exc_value = AttributeError(
              "The super constructor must be called before any other methods in "
              "your constructor. If this is not possible then annotate all the "
              "methods called with `@snt.no_name_scope`."
          )
          raise exc_value from exc_value_from
  
      with module_name_scope:
          # snt.Module enters the module name scope for all methods. To disable this
          # for a particular method annotate it with `@snt.no_name_scope`.
          return method(*args, **kwargs)
  
imports: import abc
  import functools
  import inspect
  import os
  import pprint
  import sys
  from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Type, TypeVar
  from sonnet.src import once
  from sonnet.src import types
  from sonnet.src import utils
  import tensorflow
label_desc: Use image node_id 6 for calling a global function with example usage: wrap_with_name_scope(method, instance, args, kwargs) and returns: method