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: vid_get_random_batch.m
    path of file: ./repos/siamese-fc/training
    
    the code of the file until where you have to start completion: % -----------------------------------------------------------------------------------------------------------------------
function [imout_z, imout_x, labels, sizes_z, sizes_x] = vid_get_random_batch(imdb, imdb_video, batch, data_dir, varargin)
%VID_GET_RANDOM_BATCH
%   returns batch of pairs of input (z and x) and labels
%   (Sizes are returned as [height, width])
%
%   Luca Bertinetto, Jack Valmadre, Joao Henriques, 2016
% -----------------------------------------------------------------------------------------------------------------------
    % Defines
    RGB = 1;
    GRAY = 2;
    TRAIN_SET = 1;
    VAL_SET = 2;
    % Default parameters
    opts.exemplarSize = [];
    opts.instanceSize = [];
    opts.frameRange = 50;
    opts.subMean = false;
    opts.colorRange = 255; % Adjust range from [0, 255] to [0, colorRange].
    opts.stats.rgbMean_z = [];
    opts.stats.rgbVariance_z = [];
    opts.stats.rgbMean_x = [];
    opts.stats.rgbVariance_x = [];
    opts.augment.translate = false;
    opts.augment.maxTranslate = []; % empty means no max
    opts.augment.stretch = false;
    opts.augment.maxStretch = 0.1;
    opts.augment.color = false;
    opts.augment.grayscale = 0;
    opts.prefetch = false;
    opts.numThreads = 12;
    opts = vl_argparse(opts, varargin);
% -----------------------------------------------------------------------------------------------------------------------
    % Determine the set (e.g. train or val) of the batch.
    batch_set = imdb.images.set(batch(1));
    % Check all images in the batch are from the same set.
    assert(all(batch_set == imdb.images.set(batch)));
    batch_size = numel(batch);
    % Decide rgb vs gray with given probabilities
    pair_types_rgb = datasample(1:2, batch_size, 'Weights', [1-opts.augment.grayscale opts.augment.grayscale]);
% -----------------------------------------------------------------------------------------------------------------------
    % randomize a subset of the imdb of batch_size - decide set of videos to sample from
    % NOTE: the purpose of imdb is to preser
    
function [imout_z, imout_x, labels, sizes_z, sizes_x] = vid_get_random_batch(imdb, imdb_video, batch, data_dir, varargin)
%VID_GET_RANDOM_BATCH
%   returns batch of pairs of input (z and x) and labels
%   (Sizes are returned as [height, width])
%
%   Luca Bertinetto, Jack Valmadre, Joao Henriques, 2016
% -----------------------------------------------------------------------------------------------------------------------
    % Defines
    RGB = 1;
    GRAY = 2;
    TRAIN_SET = 1;
    VAL_SET = 2;
    % Default parameters
    opts.exemplarSize = [];
    opts.instanceSize = [];
    opts.frameRange = 50;
    opts.subMean = false;
    opts.colorRange = 255; % Adjust range from [0, 255] to [0, colorRange].
    opts.stats.rgbMean_z = [];
    opts.stats.rgbVariance_z = [];
    opts.stats.rgbMean_x = [];
    opts.stats.rgbVariance_x = [];
    opts.augment.translate = false;
    opts.augment.maxTranslate = []; % empty means no max
    opts.augment.stretch = false;
    opts.augment.maxStretch = 0.1;
    opts.augment.color = false;
    opts.augment.grayscale = 0;
    opts.prefetch = false;
    opts.numThreads = 12;
    opts = vl_argparse(opts, varargin);
% -----------------------------------------------------------------------------------------------------------------------
    % Determine the set (e.g. train or val) of the batch.
    batch_set = imdb.images.set(batch(1));
    % Check all images in the batch are from the same set.
    assert(all(batch_set == imdb.images.set(batch)));
    batch_size = numel(batch);
    % Decide rgb vs gray with given probabilities
    pair_types_rgb = datasample(1:2, batch_size, 'Weights', [1-opts.augment.grayscale opts.augment.grayscale]);
% -----------------------------------------------------------------------------------------------------------------------
    % randomize a subset of the imdb of batch_size - decide set of videos to sample from
    % NOTE: the purpose of imdb is to preserve compatibility with MatConvNet cnn_train_dag,
    % it just defines size of an epoch and the type of batch (train/val).
    ids_set = find(imdb_video.set==batch_set);
    % sample one video for each pair
    rnd_videos = datasample(ids_set, batch_size, 'Replace', false);
    ids_pairs = rnd_videos(1:batch_size);
    % Initialize pairs
    % First load location for all pairs, all images will be loaded at once with vl_imreadjpeg
    % objects contains metadata for all the pairs of the batch
    objects = struct();
    objects.set = batch_set * uint8(ones(1, batch_size));
    objects.z = cell(1, batch_size);
    objects.x = cell(1, batch_size);
    % crops locations
    crops_z_string = cell(1, batch_size);
    crops_x_string = cell(1, batch_size);
    labels = zeros(1, batch_size);
    % final augmented crops
    imout_z = zeros(opts.exemplarSize, opts.exemplarSize, 3, batch_size, 'single');
    imout_x = zeros(opts.instanceSize, opts.instanceSize, 3, batch_size, 'single');

    for i = 1:batch_size
        % Crops from same videos, centered on the object
        labels(i) = 1;
        [objects.z{i}, objects.x{i}] = choose_pos_pair(imdb_video, ids_pairs(i), opts.frameRange);
    end