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: mk_fgraph_given_ev.m
    path of file: ./repos/bnt/BNT/general
    
    the code of the file until where you have to start completion: function fg = mk_fgraph_given_ev(G, node_sizes, factors, ev_CPD, evidence, varargin)
% MK_FGRAPH_GIVEN_EV Make a factor graph where each node has its own private evidence term
% fg = mk_fgraph(G, node_sizes, factors, ev_CPD, evidence, ...)
%
% G, node_sizes and factors are as in mk_fgraph, but they refer to the hidden nodes.
% ev_CPD{i} is a CPD for the i'th hidden node; this will be converted into a factor
% for node i using evidence{i}.
% We currently assume all hidden nodes are discrete, for simplicity.
%
% The list below gives optional arguments [default value in brackets].
% 
% equiv_class - equiv_class(i)=j  means factor node i gets its params from factors{j} [1:F]
% ev_equiv_class - ev_equiv_class(i)=j  means evidence node i gets its params from ev_CPD{j} [1:N]


N = length(node_sizes);
nfactors = length(factors);

    
function fg = mk_fgraph_given_ev(G, node_sizes, factors, ev_CPD, evidence, varargin)
% MK_FGRAPH_GIVEN_EV Make a factor graph where each node has its own private evidence term
% fg = mk_fgraph(G, node_sizes, factors, ev_CPD, evidence, ...)
%
% G, node_sizes and factors are as in mk_fgraph, but they refer to the hidden nodes.
% ev_CPD{i} is a CPD for the i'th hidden node; this will be converted into a factor
% for node i using evidence{i}.
% We currently assume all hidden nodes are discrete, for simplicity.
%
% The list below gives optional arguments [default value in brackets].
% 
% equiv_class - equiv_class(i)=j  means factor node i gets its params from factors{j} [1:F]
% ev_equiv_class - ev_equiv_class(i)=j  means evidence node i gets its params from ev_CPD{j} [1:N]


N = length(node_sizes);
nfactors = length(factors);

% default values for parameters
eclass = 1:nfactors;
ev_eclass = 1:N;

if nargin >= 6
  args = varargin;
  nargs = length(args);
  for i=1:2:nargs
    switch args{i},
     case 'equiv_class', eclass = args{i+1}; 
     case 'ev_equiv_class', ev_eclass = args{i+1}; 
     otherwise,  
      error(['invalid argument name ' args{i}]);       
    end