class_docstr: Context manager to set a sample into context.
  Then the sample will be retrievable from an arbitrary level of function calls via :func:`current_frozen_context`.
  
  There are two use cases:
  
  1. Setting a global sample so that some modules can directly create the frozen version, rather than first-create-and-freeze.
  2. Sharing default / dry-run samples when the search space is dynamically created.
  
  The implementation is basically adding another layer of empty dict on top of a global stack.
  When retrieved, all dicts in the stack will be merged, from the bottom to the top.
  When updated, only the dict on the top will be updated.
  
  Parameters
  ----------
  sample
      The sample to be set into context.
  
  Returns
  -------
  Context manager that provides a frozen context.
  
  Examples
  --------
  ::
      def some_func():
          print(frozen_context.current()['learning_rate'])  # 0.1
  
      with frozen_context({'learning_rate': 0.1}):
          some_func()
class_docstr_tok: ["Context","manager","to","set","a","sample","into","context",".","Then","the","sample","will","be","retrievable","from","an","arbitrary","level","of","function","calls","via",":","func",":","`","current_frozen_context","`",".","There","are","two","use","cases",":","1",".","Setting","a","global","sample","so","that","some","modules","can","directly","create","the","frozen","version",",","rather","than","first-create-and-freeze",".","2",".","Sharing","default","\/","dry-run","samples","when","the","search","space","is","dynamically","created",".","The","implementation","is","basically","adding","another","layer","of","empty","dict","on","top","of","a","global","stack",".","When","retrieved",",","all","dicts","in","the","stack","will","be","merged",",","from","the","bottom","to","the","top",".","When","updated",",","only","the","dict","on","the","top","will","be","updated",".","Parameters","--","--","--","--","--","sample","The","sample","to","be","set","into","context",".","Returns","--","--","--","-","Context","manager","that","provides","a","frozen","context",".","Examples","--","--","--","--",":",":","def","some_func","(",")",":","print","(","frozen_context.current","(",")","[","'learning_rate","'","]",")","#","0.1","with","frozen_context","(","{","'learning_rate","'",":","0.1","}",")",":","some_func","(",")"]
docstr: Ignore the most recent :class:`frozen_context`.
  
  This is useful in creating a search space within a ``frozen_context()`` context.
  Under the hood, it only disables the most recent one frozen context, which means,
  if it's currently in a nested with-frozen-arch context, multiple ``bypass()`` contexts is required.
  
  Examples
  --------
  >>> with frozen_context(arch_dict):
  ...     with frozen_context.bypass():
  ...         model_space = ModelSpace()
docstr_tok: ["Ignore","the","most","recent",":","class",":","`","frozen_context","`",".","This","is","useful","in","creating","a","search","space","within","a","``","frozen_context","(",")","``","context",".","Under","the","hood",",","it","only","disables","the","most","recent","one","frozen","context",",","which","means",",","if","it","'s","currently","in","a","nested","with-frozen-arch","context",",","multiple","``","bypass","(",")","``","contexts","is","required",".","Examples","--","--","--","--",">",">",">","with","frozen_context","(","arch_dict",")",":","...","with","frozen_context.bypass","(",")",":","...","model_space","=","ModelSpace","(",")"]
code: def bypass():
      """
      Ignore the most recent :class:`frozen_context`.
  
      This is useful in creating a search space within a ``frozen_context()`` context.
      Under the hood, it only disables the most recent one frozen context, which means,
      if it's currently in a nested with-frozen-arch context, multiple ``bypass()`` contexts is required.
  
      Examples
      --------
      >>> with frozen_context(arch_dict):
      ...     with frozen_context.bypass():
      ...         model_space = ModelSpace()
      """
  
      NO_CONTEXT = "_no_ctx_"
  
      sample = NO_CONTEXT  # make linter happy
      try:
          try:
              sample = ContextStack.pop(_FROZEN_CONTEXT_KEY)
          except IndexError:
              # context unavailable
              sample = NO_CONTEXT
          yield
      finally:
          if sample is not NO_CONTEXT:
              ContextStack.push(_FROZEN_CONTEXT_KEY, sample)
  
file_path: nni/nni/mutable/frozen.py
imports: from __future__ import annotations
  import logging
  from contextlib import contextmanager
  from typing import Any, Callable
  from .mutable import Mutable, Sample
  from .utils import NoContextError, ContextStack
label_desc: Use image node_id 5 for calling the frozen_context obj's underlying member method code with example usage: obj.bypass() without return types