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: auto_select_gpu.m
    path of file: ./repos/faster_rcnn/utils
    
    the code of the file until where you have to start completion: function gpu_id = auto_select_gpu()
% gpu_id = auto_select_gpu()
% Select the gpu which has the maximum free memory 
% --------------------------------------------------------
% Faster R-CNN
% Copyright (c) 2015, Shaoqing Ren
% Licensed under The MIT License [see LICENSE for details]
% --------------------------------------------------------

    % deselects all GPU devices
    gpuDevice([]);

    
function gpu_id = auto_select_gpu()
% gpu_id = auto_select_gpu()
% Select the gpu which has the maximum free memory 
% --------------------------------------------------------
% Faster R-CNN
% Copyright (c) 2015, Shaoqing Ren
% Licensed under The MIT License [see LICENSE for details]
% --------------------------------------------------------

    % deselects all GPU devices
    gpuDevice([]);

    maxFreeMemory = 0;
    for i = 1:gpuDeviceCount
        g = gpuDevice(i);
        freeMemory = g.FreeMemory();
        fprintf('GPU %d: free memory %d\n', i, freeMemory);
        if freeMemory > maxFreeMemory
            maxFreeMemory = freeMemory;
            gpu_id = i;
        end