function [args,additionalargs] = offlineSVMParameters(mdl,doclass,varargin)
%

%   Copyright 2020-2023 The MathWorks, Inc.
disallowedParams = {'Beta','Bias','Learner',...
    'Epsilon','Mu','Sigma','FitBias','BatchIndex','Standardize'};

svmParamsList = [{'Solver','BatchSize','Lambda','LearnRate','LearnRateSchedule',...
               'EstimationPeriod','Shuffle'},disallowedParams];
try
    if doclass
        modelType = "classification";
    else
        modelType = "regression";
    end
    cleanedupargs = incremental.utils.partialMatchParameters(svmParamsList,modelType,varargin{:});
    additionalargs = incremental.utils.validateDisallowedParameters(mdl,disallowedParams,cleanedupargs);
    assert(isequal(mdl.KernelParameters.Function,'linear'),message('stats:incremental:Offline:SVMNonLinearKernel'));
    args = struct();
    if isfield(additionalargs,'Solver')
        args.Solver = validatestring(additionalargs.Solver,{'sgd','asgd','scale-invariant'},mfilename,'Solver');
    else
        additionalargs = incremental.utils.validateDisallowedParameters(mdl,{'LearnRate','LearnRateSchedule','BatchSize','Lambda'},additionalargs);
        args.Solver = 'scale-invariant';
    end
    
    args.Learner = 'svm';

     % Check that Beta and Bias aren't gpuArrays.
     if isa(mdl.Beta, "gpuArray") || isa(mdl.Bias, "gpuArray")
         error(message("stats:incremental:Offline:GPUFittedModelNotSupported"));
     end

    % Scale will always have a value for linear models (Default value is 1.0)
    args.Beta = mdl.Beta./mdl.KernelParameters.Scale;
    args.Bias = mdl.Bias;
    
    % It is expected that Epsilon, Mu and Sigma cannot be gpuArrays without
    % Beta and Bias being gpuArrays (which has been checked above), so the
    % checks for these properties below use ASSERT instead of ERROR.
    if ~isempty(mdl.Mu)
        assert(~isa(mdl.Mu, "gpuArray"), message("stats:incremental:Offline:GPUFittedModelNotSupported"));
        assert(~isa(mdl.Sigma, "gpuArray"), message("stats:incremental:Offline:GPUFittedModelNotSupported"));
        args.Mu = mdl.Mu;
        args.Sigma = mdl.Sigma;
    end
    if ~isempty(mdl.Impl.Epsilon)
        assert(~isa(mdl.Impl.Epsilon, "gpuArray"), message("stats:incremental:Offline:GPUFittedModelNotSupported"));
        args.Epsilon = mdl.Impl.Epsilon;
    end
catch ME
    throwAsCaller(ME);
end
end
