code: def unique_and_canonical_name(name: str) -> str:
      """Returns a canonical name for the given name."""
      frame = base.current_frame()
  
      # If we are outside init/call then prefix the name with the method name.
      if len(frame.module_stack) > 1:
          # -2 since we are inside the ctor and want to look at the caller state.
          module_state = frame.module_stack.peek(-2)
  
          # Make sure to include the method name if appropriate.
          method_name = module_state.method_name
          if method_name == "__init__":
              name = "~/" + name
          elif method_name != "__call__":
              name = "~" + method_name + "/" + name
  
          # Include the parent name.
          parent_module = module_state.module
          parent_name = base.safe_get_module_name(parent_module)
          name = parent_name + "/" + name
  
      # Test if the user has explicitly numbered this module.
      name, n = name_and_number(name)
      explicit_n = n is not None
  
      # Determine a unique name for this module within the current context.
      if n is None:
          n = next_module_number(name)
      name = f"{name}_{n}" if explicit_n or n else name
  
      # Final sanity check that this name has not been used before.
      reserve_module_name(name, check_unique=True)
  
      return 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 8 for calling a global function with example usage: unique_and_canonical_name(name) and returns: name