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: pearl_unrolled_dbn_inf_engine.m
    path of file: ./repos/bnt/BNT/inference/dynamic/@pearl_unrolled_dbn_inf_engine
    
    the code of the file until where you have to start completion: function engine = pearl_unrolled_dbn_inf_engine(bnet, varargin)
% LOOPY_DBN_INF_ENGINE Loopy Pearl version of forwards-backwards
% engine = loopy_unrolld_dbn_inf_engine(bnet, ...)
%
% Optional arguments
% 'max_iter' - specifies the max num. forward-backward passes to perform PER SLICE [2]
% 'tol' - as in loopy_pearl [1e-3]
% 'momentum' - as in loopy_pearl [0]
% protocol - tree or parallel [parallel]

    
function engine = pearl_unrolled_dbn_inf_engine(bnet, varargin)
% LOOPY_DBN_INF_ENGINE Loopy Pearl version of forwards-backwards
% engine = loopy_unrolld_dbn_inf_engine(bnet, ...)
%
% Optional arguments
% 'max_iter' - specifies the max num. forward-backward passes to perform PER SLICE [2]
% 'tol' - as in loopy_pearl [1e-3]
% 'momentum' - as in loopy_pearl [0]
% protocol - tree or parallel [parallel]
% filename - as in pearl [ '' ]

max_iter_per_slice = 2;
tol = 1e-3;
momentum = 0;
protocol = 'parallel';
filename = '';

args = varargin;
for i=1:2:length(args)
  switch args{i},
   case 'max_iter', max_iter_per_slice = args{i+1};
   case 'tol', tol = args{i+1};
   case 'momentum', momentum = args{i+1};
   case 'protocol', protocol = args{i+1};
   case 'filename', filename = args{i+1};
  end