code: def smart_where(condition, x_fn, y_fn):
      """As tf.where, but only calls x_fn/y_fn when condition not statically known.
  
      IMPORTANT: Since this avoids executing the inoperative branch when possible,
      it will not necessarily broadcast `x_fn()` with `y_fn()`, so it is imperative
      that they return `Tensor`s which broadcast with `condition` to the same final
      shape.
  
      Args:
        condition: A `bool` Tensor.
        x_fn: A callable returning a `Tensor`, for locations where `condition` is
          `True`.
        y_fn: A callable returning a `Tensor`, for locations where `condition` is
          `False`.
  
      Returns:
        A `Tensor` equivalent to `tf.where(condition, x_fn(), y_fn())`.
      """
      cond_static = _get_static_value(condition)
      if cond_static is not None:
          if np.size(cond_static) == 1 and cond_static in (
              0,
              1,
              False,
              True,
          ):
              return x_fn() if bool(cond_static) else y_fn()
          elif isinstance(cond_static, (np.ndarray, np.generic)):
              if np.all(cond_static):
                  x = x_fn()
                  return tf.broadcast_to(
                      x,
                      tf.broadcast_dynamic_shape(
                          tf.shape(x), tf.shape(condition)
                      ),
                  )
              elif not np.any(cond_static):
                  y = y_fn()
                  return tf.broadcast_to(
                      y,
                      tf.broadcast_dynamic_shape(
                          tf.shape(y), tf.shape(condition)
                      ),
                  )
      return tf.where(condition, x_fn(), y_fn())
  
imports: import decorator
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal.backend import numpy
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import control_flow_case
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 8 for calling a global function with example usage: smart_where(condition, x_fn, y_fn) and returns: tf, unknown, tf, tf