code: def smart_cond(pred, true_fn=None, false_fn=None, name=None):
      """Return either `true_fn()` if predicate `pred` is true else `false_fn()`.
  
      If `pred` is a bool or has a constant value, we return either `true_fn()`
      or `false_fn()`, otherwise we use `tf.cond` to dynamically route to both.
  
      Args:
        pred: A scalar determining whether to return the result of `true_fn` or
          `false_fn`.
        true_fn: The callable to be performed if pred is true.
        false_fn: The callable to be performed if pred is false.
        name: Optional name prefix when using `tf.cond`.
  
      Returns:
        Tensors returned by the call to either `true_fn` or `false_fn`.
  
      Raises:
        TypeError: If `true_fn` or `false_fn` is not callable.
      """
      if not callable(true_fn):
          raise TypeError(
              f"Argument `true_fn` must be callable. Received {true_fn}"
          )
      if not callable(false_fn):
          raise TypeError(
              f"Argument `false_fn` must be callable. Received {false_fn}"
          )
  
      pred_value = smart_constant_value(pred)
      if pred_value is not None:
          if pred_value:
              return true_fn()
          else:
              return false_fn()
      else:
          return cond.cond(
              pred, true_fn=true_fn, false_fn=false_fn, name=name
          )
  
imports: from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import control_flow_case
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 1 for calling a global function with example usage: smart_cond(pred, true_fn, false_fn, name) and returns: cond, true_fn, false_fn