function layer = preluLayer(nameValueArgs)

%   Copyright 2023 The MathWorks, Inc.

% Declare input argument restrictions.
arguments
    nameValueArgs.Alpha {mustBeNumeric, mustBeFinite, iAssertValidAlpha} = 0.25 
    nameValueArgs.Name {iAssertValidLayerName} = ''
end

layer = nnet.cnn.layer.PReLULayer(nameValueArgs.Alpha, nameValueArgs.Name);

end

function iAssertValidLayerName(name)
nnet.internal.cnn.layer.paramvalidation.validateLayerName(name);
end

function iAssertValidAlpha(alpha)
% Formatted dlarrays will be stripped of their labels during initialization
% in custom layers, leading to obscure size mismatch errors. Users must 
% specify Alpha as a numeric, unformatted array. 
if isdlarray(alpha) && ~isempty(dims(alpha))
    error( message('nnet_cnn:layer:PReLULayer:AlphaCannotBeFormatted') );    
end
end
