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: gen_network_pool_block.m
    path of file: ./repos/refinenet/main
    
    the code of the file until where you have to start completion: 
function layer_gen_info=gen_network_pool_block(refine_config, dag_net, layer_gen_info, layer_name_prefix)

    if ~refine_config.use_chained_pool
        return;
    end

    % original implmentation:
	% layer_gen_info=do_gen_block(refine_config, dag_net, layer_gen_info, layer_name_prefix);
		
    % improved version:
	layer_gen_info=do_gen_block_convbeforepool(refine_config, dag_net, layer_gen_info, layer_name_prefix);

end




function [outputs, one_output_dim]=add_joint_layer_dagnn(dag_net, inputs, name, use_concat, joint_input_dims)


outputs={[name '_varout']};

if use_concat
    block = My_concat_layer() ;
else
    block = My_sum_layer() ;
end

assert(isa(inputs, 'cell'));
if size(inputs, 1)>1
    inputs=inputs';
    joint_input_dims=joint_input_dims';
end
block.numInputs=length(inputs);

dag_net.addLayer(...
    name, ...
    block, ...
    inputs, ...
    outputs, ...
    {}) ;


if use_concat
            
    one_output_dim=sum(joint_input_dims);
    
    feat_dim_before=one_output_dim;
   

    assert(all(joint_input_dims==joint_input_dims(1)));
    feat_dim_after=joint_input_dims(1);

    outputs=My_net_util.add_dim_reduce_layer(dag_net, outputs{1}, feat_dim_before,
    
function layer_gen_info=do_gen_block_convbeforepool(refine_config, dag_net, layer_gen_info, layer_name_prefix)

	
    one_outputs=layer_gen_info.one_outputs;
    one_outputs=My_net_util.add_relu_dagnn(dag_net, [layer_name_prefix '_poolprev'], one_outputs);
    layer_gen_info.one_outputs=one_outputs;


    pool_num=refine_config.chained_pool_num;
    pool_size=refine_config.chained_pool_size;

    assert(pool_num>=1);

    one_output_dim=layer_gen_info.one_output_dim;
        
    one_outputs=layer_gen_info.one_outputs;
    pool_outputs=one_outputs;


                
    for p_idx=1:pool_num


    	feat_dim_before=one_output_dim;
        feat_dim_after=one_output_dim;

        dim_adapt_name=sprintf([one_outputs{1} '_pb%d'], p_idx);
        one_outputs=My_net_util.add_dim_reduce_layer_named(dag_net, one_outputs{1}, feat_dim_before, feat_dim_after, dim_adapt_name);

        
        block = dagnn.Pooling() ;
        block.method = 'max' ;
        block.poolSize = [pool_size pool_size] ;
        block.pad =  floor(pool_size./2); 
        block.stride = 1 ;
                
        layer_name=sprintf([layer_name_prefix '_pool%d'], p_idx);
        
        one_inputs=one_outputs;
        
        one_outputs={[layer_name, '_outvar']};
        
        dag_net.addLayer(...
            layer_name, ...
            block, ...
            one_inputs, ...
            one_outputs, ...
            {}) ;
                        
        
        pool_outputs=cat(2, pool_outputs, one_outputs);
        
    end