code: def scope(dtype: tf.DType):
      """Temporarily set the global mixed precision type to dtype.
  
      The global type is reset to its original value when the context is exited.::
  
          snt.mixed_precision.enable(tf.float32)
          support_modes = snt.mixed_precision.modes([tf.float32, tf.float16])
          snt.Linear.__call__ = support_modes(snt.Linear.__call__)
          mod = snt.Linear(10)
  
          with snt.mixed_precision.scope(tf.float16):
              y = mod(tf.ones([1, 1]))  # First call will be done in F32.
              y = mod(tf.ones([1, 1]))  # MatMul/Add will be done in F16.
          y = mod(tf.ones([1, 1]))  # Outside the scope will be done in F32.
  
      Args:
        dtype: type to set the mixed precision mode to.
  
      Yields:
        Nothing. This is required for contextlib.contextmanager.
      """
      # TODO(petebu) Make this a doctest once python2 is deprecated
      old_mode = _get_mixed_precision_mode()
      enable(dtype)
      try:
          yield
      finally:
          enable(old_mode)
  
file_path: sonnet/sonnet/src/mixed_precision.py
imports: import uuid
  import contextlib
  from sonnet.src import custom_getter
  from sonnet.src import utils
  import tensorflow
  import tree
label_desc: Use image node_id 8 for calling a global function with example usage: scope(dtype) without return types