def pooling_output_shape(dimension_size, pool_size, padding, stride,
                         ignore_border=True):
    """
    Computes output shape for pooling operation.

    Parameters
    ----------
    dimension_size : int
        Size of the dimension. Typically it's image's
        weight or height.

    filter_size : int
        Size of the pooling filter.

    padding : int
        Size of the zero-padding.

    stride : int
        Stride size.

    ignore_border : bool
        Defaults to ``True``.

    Returns
    -------
    int
    """
    if dimension_size is None:
        return None

    if ignore_border:
        output_size = dimension_size + 2 * padding - pool_size + 1
        output_size = (output_size + stride - 1) // stride

    elif stride >= pool_size:
        output_size = (dimension_size + stride - 1) // stride

    else:
        output_size = (dimension_size - pool_size + stride - 1) // stride
        output_size = max(1, output_size + 1)

    return output_size