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: marginal_nodes.m
    path of file: ./repos/bnt/BNT/inference/static/@gibbs_sampling_inf_engine
    
    the code of the file until where you have to start completion: function [marginal, engine] = marginal_nodes(engine, nodes, varargin);
% MARGINAL_NODES Compute the marginal on the specified query nodes
% (gibbs_sampling_engine)
% [marginal, engine] = marginal_nodes(engine, nodes, ...)
%
% returns Pr(X(nodes) | X(observedNodes))
%
% The engine is also modified, and so it is returned as well, since
% Matlab doesn't support passing by reference(!)  So

    
function [marginal, engine] = marginal_nodes(engine, nodes, varargin);
% MARGINAL_NODES Compute the marginal on the specified query nodes
% (gibbs_sampling_engine)
% [marginal, engine] = marginal_nodes(engine, nodes, ...)
%
% returns Pr(X(nodes) | X(observedNodes))
%
% The engine is also modified, and so it is returned as well, since
% Matlab doesn't support passing by reference(!)  So
% if you want to, for example, incrementally run gibbs for a few 100
% steps at a time, you should use the returned value.
%
% Optional arguments :
%
% 'reset_counts' is 1 if you want to reset the counts made in the
% past, and 0 otherwise (if the current query nodes are different
% from the previous query nodes, or if marginal_nodes has not been
% called before, reset_counts should be set to 1).
% By default it is 1.


reset_counts = 1;

if (nargin > 3)
  args = varargin;
  nargs = length(args);
  for i = 1:2:nargs
    switch args{i}
     case 'reset_counts'
      reset_counts = args{i+1};
     otherwise
      error(['Incorrect argument to gibbs_sampling_engine/' ...
	     ' marginal_nodes']);
    end