You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: max_pooling2.m
    path of file: ./repos/OpenFace/matlab_version/face_detection/mtcnn
    
    the code of the file until where you have to start completion: function [ output_maps ] = max_pooling2( input_maps, kernel_size, stride)
%POOLING Summary of this function goes here
%   Detailed explanation goes here
    
    orig_rows = size(input_maps,1);
    orig_cols = size(input_maps,2);
    
    pooled_rows = round((orig_rows - kernel_size)/stride) + 1;
    pooled_cols = round((orig_cols - kernel_size)/stride) + 1;   
     
    if(exist('vl_nnpool', 'file') == 3)
        % Caffe and MatConvNet do pooling slightly differently, so need to
        % counter for that

        pooled_cols_vl = floor((orig_cols - kernel_size)/stride) + 1;
        pooled_rows_vl = floor((orig_rows - kernel_size)/stride) + 1;

        if(pooled_rows_vl == pooled_rows && pooled_cols_vl == pooled_cols)

    
function [ output_maps ] = max_pooling2( input_maps, kernel_size, stride)
%POOLING Summary of this function goes here
%   Detailed explanation goes here
    
    orig_rows = size(input_maps,1);
    orig_cols = size(input_maps,2);
    
    pooled_rows = round((orig_rows - kernel_size)/stride) + 1;
    pooled_cols = round((orig_cols - kernel_size)/stride) + 1;   
     
    if(exist('vl_nnpool', 'file') == 3)
        % Caffe and MatConvNet do pooling slightly differently, so need to
        % counter for that

        pooled_cols_vl = floor((orig_cols - kernel_size)/stride) + 1;
        pooled_rows_vl = floor((orig_rows - kernel_size)/stride) + 1;

        if(pooled_rows_vl == pooled_rows && pooled_cols_vl == pooled_cols)
            output_maps = vl_nnpool(input_maps, [kernel_size, kernel_size], 'stride', stride);
        else
            % Else need to pad right and bottom with infinities 
            for x=1:kernel_size
                pooled_cols_vl = floor((orig_cols + x - kernel_size)/stride) + 1;
                if(pooled_cols_vl == pooled_cols)
                    break;
                end