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: cnn_vecms_sketch.m
    path of file: ./repos/cnnimageretrieval/cnnvecs
    
    the code of the file until where you have to start completion: function v = cnn_vecms_sketch(im, net, emodel, scales, mirror, aggregate)
% CNN_VECMS_SKETCH computes a multi-scale D-dimensional CNN sketch vector for an image.
%
%   V = cnn_vecms_sketch(IM, NET, EMODEL, SCALES, MIRROR, AGGREGATE)
%   
%   IM        : Input image, or input image path as a string
%   NET       : CNN network to evaluate on image IM
%   EMODEL    : Edge detector model, 0 means do not extract edges because input is already sketch
%   SCALES    : Vector of scales to resize image prior to the descri
    
function v = cnn_vec_edge(im, net)
% CNN_VEC_EDGE computes a D-dimensional CNN edge vector for a given edge-map.
%
%   V = cnn_vec_edge(IM, NET)
%   
%   IM  : Input edge-map
%   NET : CNN network to evaluate on image IM
%
%   V   : D-dimensional vector
%
% Authors: F. Radenovic, G. Tolias, O. Chum. 2018. 

    minsize = 67;
    net.mode = 'test';
    descvarname = 'l2descriptor';

    use_gpu = strcmp(net.device, 'gpu');
    if use_gpu
        gpuarrayfun = @(x) gpuArray(x);
        gatherfun = @(x) gather(x);
    else
        gpuarrayfun = @(x) x; % do not convert to gpuArray
        gatherfun = @(x) x; % do not gather
    end