def _PadLabels2d(logits_size, labels):
 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)

def _PadLabels2d ( logits_size , labels ) : 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 )
pads or slices the 2nd dimension of 2-d labels to match logits_size .