human
Complete the below
def _PadLabels2d(logits_size, labels):

    ''''Pads or slices the 2nd dimension of 2-d labels to match logits_size.
    Covers the case of 1-d softmax output, when labels is [batch, seq] and
    logits is [batch, seq, onehot]
    Args:
    logits_size: Tensor returned from tf.shape giving the target size.
    labels:      2-d, but not necessarily matching in size.
    Returns:
    labels: Resized by padding or clipping the last dimension to logits_size.'
    '''

=====
Give me a the Python program you requested?
assistant
#Here is the Python program you requested.
    pad = (logits_size - tf.shape(labels)[1])
    def _PadFn():
        return tf.pad(labels, [[0, 0], [0, pad]])
    def _SliceFn():
        return tf.slice(labels, [0, 0], [(-1), logits_size])
    return tf.cond(tf.greater(pad, 0), _PadFn, _SliceFn)