I don't think there is a direct analog of 'nargin' in IML, however you could achieve the same effect by giving the input matrix B a blank default value, and then testing the type of matrix B, it will be undefined(U) if the call to the function has not provided a matrix B, or it will be numeric (N) if a value for B is given. The syntax would be along the following lines:
start mytrace(A, B=);
if type(B)='U' then return(trace(A)); else etc..;
finish;