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: viterbi.m
    path of file: ./repos/Computer-Vision-and-AI/HMM-Functions
    
    the code of the file until where you have to start completion: 
function [x,mt,at] = viterbi(p,q,e,f0)
%
% function [x,mt,at] = viterbi(p,q,e,f0)
%
% INPUTS
%   p = n x n matrix, state transition model = P(X_{t+1}|X_t)
    
function [x,mt,at] = viterbi(p,q,e,f0)
%
% function [x,mt,at] = viterbi(p,q,e,f0)
%
% INPUTS
%   p = n x n matrix, state transition model = P(X_{t+1}|X_t)
%       where n = number of possible values for the state X
%   q = m x n matrix, sensor model = P(e_t|X_t)
%       where m = number of possible values for the evidence 
%   e = 1 x t, sequence of evidence
%       where t is the current time step 
%   f0 = n x 1 vector, initial message, default = ones(n,1)/n
%
% OUTPUTS
%   x = 1 x t vector, most likely sequence from time 1 to t  
%   mt = n x t vector, message from time 1 to t
%       each column is \max_{x_{1:t-1}} P(x_{1:t-1},X_t|e_{1:t})
%   at = n x t vector, best transition leading to each state
%       each column is \arg \max_{x_t} ( P(X_{t+1}|x_t) m_{1:t} )

% TJ Keemon <keemon@bc.edu>
% March 5, 2009

if nargin < 1
    help viterbi
    return
end