from typing import Tuple


def output_shape_conv_and_pool_layer(rows: int,
                                     columns: int,
                                     kernel: int,
                                     stride: int = 1,
                                     padding: int = 0,
                                     dilatation: float = 1.) -> Tuple[int, int]:
    """
    Calculate the size of a convolutional or maxpooling layer.

    The formula used comes directly from PyTorch documentation.

    :param rows: number of rows of input
    :param columns: number of columns of inputs
    :param kernel: kernel size of current layer
    :param stride: stride setting of current layer
    :param padding: padding setting of current layer
    :param dilatation: dilatation setting of current layer
    :return: shape of layer
    """
    return (
        int((rows + 2 * padding - dilatation * (kernel - 1) - 1) / stride + 1),
        int((columns + 2 * padding - dilatation * (kernel - 1) - 1) / stride + 1),
    )