def ComputeConvOutputPadding(paddings, window, stride, padding_algorithm='SAME'):
    "Computes paddings for convolution and pooling output.\n\n  out_padding[i] == 1 iff any in_padding corresponding to that output is 1.\n\n  Args:\n    paddings: The paddings tensor. It is expected to be of shape [batch, time].\n    window: The size of the windows.\n    stride: The time-stride between adjacent windows.\n    padding_algorithm: 'SAME' or 'VALID'.\n\n  Returns:\n    out_padding, The new padding tensor of size [batch, ceil(time / stride)].\n  "
    if (stride == 1):
        return paddings
    input_length = py_utils.GetShape(paddings)[1]
    pad_len = (((((input_length + stride) - 1) // stride) * stride) - input_length)
    paddings = tf.pad(paddings, [[0, 0], [0, pad_len]], constant_values=1.0)
    out_padding = tf.nn.pool(tf.expand_dims(paddings, (- 1)), [window], 'MAX', padding_algorithm, strides=[stride])
    return tf.squeeze(out_padding, (- 1))
Computes paddings for convolution and pooling output.

out_padding[i] == 1 iff any in_padding corresponding to that output is 1.

Args:
  paddings: The paddings tensor. It is expected to be of shape [batch, time].
  window: The size of the windows.
  stride: The time-stride between adjacent windows.
  padding_algorithm: 'SAME' or 'VALID'.

Returns:
  out_padding, The new padding tensor of size [batch, ceil(time / stride)].
def ComputeConvOutputPadding(paddings, window, stride, padding_algorithm='SAME'):
    "Computes paddings for convolution and pooling output.\n\n  out_padding[i] == 1 iff any in_padding corresponding to that output is 1.\n\n  Args:\n    paddings: The paddings tensor. It is expected to be of shape [batch, time].\n    window: The size of the windows.\n    stride: The time-stride between adjacent windows.\n    padding_algorithm: 'SAME' or 'VALID'.\n\n  Returns:\n    out_padding, The new padding tensor of size [batch, ceil(time / stride)].\n  "
    if (stride == 1):
        return paddings
    input_length = py_utils.GetShape(paddings)[1]
    pad_len = (((((input_length + stride) - 1) // stride) * stride) - input_length)
    paddings = tf.pad(paddings, [[0, 0], [0, pad_len]], constant_values=1.0)
    out_padding = tf.nn.pool(tf.expand_dims(paddings, (- 1)), [window], 'MAX', padding_algorithm, strides=[stride])
    return tf.squeeze(out_padding, (- 1))