<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build_or_reuse_placeholder(tensor_spec):
 """ Build a tf.placeholder from the metadata in the given tensor spec, or return an existing one. Args: tensor_spec (tf.TensorSpec):
 Returns: tf.Tensor: """

    g = tfv1.get_default_graph()
    name = tensor_spec.name
    try:
        tensor = g.get_tensor_by_name(name + ':0')
        assert "Placeholder" in tensor.op.type, "Tensor {} exists but is not a placeholder!".format(name)
        assert tensor_spec.is_compatible_with(tensor), \
            "Tensor {} exists but is not compatible with the signature!".format(tensor)
        return tensor
    except KeyError:
        with tfv1.name_scope(None):   # clear any name scope it might get called in
            ret = tfv1.placeholder(
                tensor_spec.dtype, shape=tensor_spec.shape, name=tensor_spec.name)
        return ret