code: def tfcompile(
      func=None,
      tf_function=True,
      xla_best_effort=True,
      xla_compile_all=False,
  ):
      """Centralizes TF compilation related options.
  
      Args:
        func: Python `callable` to wrapped with the specified TF compilation
          directives.
          Default value: `None`.
        tf_function: `bool` representing whether the resulting function should be
          `tf.function` decoreated.
          Default value: `True`.
        xla_best_effort: `bool` representing whether XLA auto-clustering compilation
          should be performed. (This argument is ignored if the function is executed
          eagerly.)
          Default value: `True`.
        xla_compile_all: `bool` representing whether XLA compilation should be
          performed. (This argument overrides both `tf_function` and
          `xla_best_effort`.
          Default value: `False`.
  
      Returns:
        wrapped_func: A Python `callable` with the specified compilation directives
          embedded.
  
      ### Example Usage
  
      ```python
      tfn = tfp.experimental.nn
  
      # Use style #1.
      @tfn.util.tfcompile(xla_compile_all=True)
      def foo(...):
           ...
  
      # Use style #2.
      def foo(...):
        ...
      foo = tfn.util.tfcompile(xla_compile_all=True)(foo)
      ```
  
      """
      if not (tf_function or xla_best_effort or xla_compile_all):
          # This specialization makes for smaller stack trace and easier debugging.
          return lambda fn: fn if func is None else func
  
      # Note: xla_compile_all overrides both tf_function and xla_best_effort.
      tf_function = tf_function or xla_compile_all
      xla_best_effort = xla_best_effort and not xla_compile_all
      maybe_tf_function = (
          tf.function(autograph=False, jit_compile=xla_compile_all)
          if tf_function
          else _dummy_context()
      )
  
      def decorator(f):
          @functools.wraps(f)
          @maybe_tf_function
          def wrapped(*args, **kwargs):
              maybe_xla_best_effort = (
                  tf.xla.experimental.jit_scope(compile_ops=True)
                  if not tf.executing_eagerly() and xla_best_effort
                  else _dummy_context()
              )
              with maybe_xla_best_effort:
                  return f(*args, **kwargs)
  
          return wrapped
  
      if func is None:
          # This branch handles the following use case:
          #   @tfcompile(...)
          #   def foo(...):
          #      ...
          return decorator
      else:
          # This branch handles the following use case:
          #   foo = tfcompile(...)(foo)
          return decorator(func)
  
imports: import collections
  import contextlib
  import functools
  import sys
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensorshape_util
label_desc: Use image node_id 4 for calling a global function with example usage: tfcompile(func, tf_function, xla_best_effort, xla_compile_all) and returns: function, wrapped, decorator, decorator, f