def kronecker_product(matrices):
    """
    Performs Kronecker product of a list of matrices.
    Args:
        - matrices (a list of matrices)
    Returns:
        - matrix - the result of kronecker_product of matrices
    """
    if len(matrices) < 1:
        return RuntimeError('The input should be a list of matrices.')

    if len(matrices) == 1:
        return matrices[0]

    if len(matrices) > 1:
        matrix_0 = matrices[0]
        matrix_1 = kronecker_product(matrices[1:])
        size_0 = matrix_0.size()
        size_1 = matrix_1.size()
        res = matrix_0.contiguous().view(-1).unsqueeze(1) * matrix_1.contiguous().view(-1).unsqueeze(0)
        res = res.view(size_0[0], size_0[1], size_1[0], size_1[1])
        res = res.transpose(1, 2).contiguous().view(size_0[0] * size_1[0], size_0[1] * size_1[1])
        return res