def with_dependencies(dependencies, output_tensor, name=None):
  """
  """
  if tf.executing_eagerly():
    return output_tensor
  with tf.name_scope(name or "control_dependency") as name:
    with tf.control_dependencies(d for d in dependencies if d is not None):
      output_tensor = tf.convert_to_tensor(value=output_tensor)
      if isinstance(output_tensor, tf.Tensor):
        return tf.identity(output_tensor, name=name)
      else:
        return tf.IndexedSlices(
            tf.identity(output_tensor.values, name=name),
            output_tensor.indices,
            output_tensor.dense_shape)