code: def _broadcast_with(tensor, shape):
      """Like broadcast_to, but allows singletons in the destination shape."""
      res = tf.broadcast_to(
          tensor, ps.broadcast_shape(ps.shape(tensor), shape)
      )
      # We need this done explicitly because ps.broadcast_shape cannot deal with
      # partially specified shapes.
      tensorshape_util.set_shape(
          res,
          tf.broadcast_static_shape(
              tensor.shape, tf.TensorShape(tf.get_static_value(shape))
          ),
      )
      return res
  
imports: import itertools
  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 14 for calling a global function with example usage: _broadcast_with(tensor, shape) and returns: res