code: def val_where(cond, tval, fval):
      """Like tf.where but works on namedtuples."""
      if isinstance(tval, tf.Tensor):
          return broadcast_util.where_left_justified_mask(
              cond, tval, fval
          )
      elif isinstance(tval, tuple):
          cls = type(tval)
          return cls(
              *(val_where(cond, t, f) for t, f in zip(tval, fval))
          )
      else:
          raise Exception(TypeError)
  
file_path: probability/tensorflow_probability/python/optimizer/linesearch/internal/hager_zhang_lib.py
imports: import collections
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import broadcast_util
  from tensorflow_probability.python.internal import prefer_static
label_desc: Use image node_id 1 for calling a global function with example usage: val_where(cond, tval, fval) and returns: broadcast_util, cls