code: def _mixed_precision_interceptor(
      next_f, args, kwargs, context: hk.MethodContext
  ):
      """Method interceptor used to apply mixed precision policies to classes."""
      policy = get_policy(type(context.module))
      if policy is None:
          return next_f(*args, **kwargs)
  
      ctx = contextlib.ExitStack()
      with ctx:
          if not _thread_local_state.has_current_policy:
              ctx.enter_context(
                  hk.custom_creator(_mixed_precision_creator)
              )
              ctx.enter_context(
                  hk.custom_getter(_mixed_precision_getter, state=True)
              )
          ctx.enter_context(
              _thread_local_state.push_current_policy(policy)
          )
  
          args, kwargs = policy.cast_to_compute((args, kwargs))
          out = next_f(*args, **kwargs)
          return policy.cast_to_output(out)
  
imports: import collections
  import contextlib
  import threading
  from typing import TypeVar, Optional, Union
  from haiku._src import base
  from haiku._src import data_structures
  from haiku._src import module
  import jmp
label_desc: Use image node_id 10 for calling a global function with example usage: _mixed_precision_interceptor(next_f, args, kwargs, context) and returns: next_f, policy