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: Bag_KI_SVM.m
    path of file: ./repos/MCITF/Code/MCITF/KISVM/Bag KI-SVM
    
    the code of the file until where you have to start completion: function [test_bag_label, test_inst_label, test_bag_pre, test_ins_pre] = Bag_KI_SVM(opt, train_data, test_data)
%Bag_KI_SVM is a convex method for locating Region Of Interest(ROI) with multi-instance learning 

    
function [test_bag_label, test_inst_label, test_bag_pre, test_ins_pre] = Bag_KI_SVM(opt, train_data, test_data)
%Bag_KI_SVM is a convex method for locating Region Of Interest(ROI) with multi-instance learning 
%
%N.B.: Bag_KI_SVM employs a new Matlab software (libsvm-mat-2.88-MI-SVM)
%
%    Syntax
%
%       function [test_bag_label, test_inst_label, test_bag_pre, test_ins_pre] = Bag_KI_SVM(opt, train_data, test_data)
%
%    Description
%
%       Bag_KI_SVM takes,
%           opt          - A struct, includes the parameters. 
%                        1)opt.gaussian. If opt.gaussian = 1 means rbf
%                        kernel is used; If opt.gaussian = 0 means linear
%                        kernel is used; [Default opt.gaussian = 0]
%                        2)opt.ratio. If rbf kernel K(x,y) =
%                        exp(-||x-y||^2/2*ratio^2*width) is used, the
%                        opt.ratio = ratio. Here width is average distance
%                        between all instances.  [Default opt.ratio = 1]
%                        3)opt.im_ratio. Imbalance ratio for positive
%                        bags.[Default opt.im_ratio = 1]
%                        4)opt.C. The regularization term in SVM [Default
%                        opt.C = 1] 
%                        5)opt.iteration. The maximal iteration for label
%                        generation.[Default opt.iteration = 20]
%                        6)opt.minstep. The minimal iteration for label
%                        genernation. [Default opt.minstep = 5]
%           train_data   - An Nx2 cell,the jth instance of the ith training
%                          bag is stored in train_data{i,1}(j,:), the ith label of the ith
%                           training bag is stored in  train_data{i,2}
%           test_data    - A M*2 cell, the jth instance of the ith training
%                          bag is stored in train_data{i,1}(j,:). the ith label of the ith
%                           training bag is set as  train_data{i,2} = 0; The label of testing bags will not be used.  

%      and returns,
%           test_bag_label    - An M*1 array, the predicted label of the ith testing bags is stored
%                               in test_bag_label(i)
%           test_inst_label   - An Mx1 cell,  the predicted label of the
%                               jth instance of the ith training bag is stored in the test_inst_label{i,1}(j) 
%           test_bag_pre      - An M*1 array, the prediction of the ith testing bags is stored
%                               in test_bag_label(i)
%           test_ins_pre      - An Mx1 cell,  the prediction label of the
%                               jth instance of the ith training bag is
%                               stored in the test_inst_label{i,1}(j)                             
%
% [1] Y.-F. Li, J. T. Kwok, I. W. Tsang, and Z.-H. Zhou. A convex method for locating regions of interest with multi-instance learning. In: Proceedings of the 20th European Conference on Machine Learning (ECML'09), Bled, Slovenia, 2009. 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % add path
% addpath('libsvm-mat-2.88-MI-svm');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if ~isfield(opt,'gaussian')
    opt.gaussian = 0;
end