def _padding_arg(h, w, input_format):
  """Calculate the padding shape for tf.pad().

  Args:
    h: (int) padding on the height dim.
    w: (int) padding on the width dim.
    input_format: (string) the input format as in 'NHWC' or 'HWC'.
  Raises:
    ValueError: If input_format is not 'NHWC' or 'HWC'.

  Returns:
    A two dimension array representing the padding argument.
  """
  if input_format == 'NHWC':
    return [[0, 0], [h, h], [w, w], [0, 0]]
  elif input_format == 'HWC':
    return [[h, h], [w, w], [0, 0]]
  else:
    raise ValueError('Input Format %s is not supported.' % input_format)