function layer = indexing1dLayer(index,nameValueArgs)
%indexing1dLayer   1-D indexing layer
%
%   LAYER = indexing1dLayer creates a layer that extracts the data given by
%   the first index of the time or spatial dimensions of the input data.
%
%   LAYER = indexing1dLayer(INDEX) specifies where to index into the input
%   data. If INDEX is "first", then the layer extracts the first index of the
%   input. If INDEX is "last", then the layer extracts the last index of the
%   input.
%
%   LAYER = indexing1dLayer(__,Name=Value) specifies additional options using
%   one or more name-value arguments:
%
%     HasPaddingMaskInput      - Flag indicating whether the layer has an
%                                extra input that represents the padding
%                                mask, specified as 1 (true) or 0 (false).
%                                If HasPaddingMaskInput is 1 (true), then
%                                the layer has an extra input with the name
%                                "mask". The padding mask input must be a
%                                logical array or numeric array consisting
%                                of 0 and 1. The software prevents and
%                                allows attention to elements in
%                                keys-values pairs when the corresponding
%                                element in the padding mask is 0 and 1
%                                respectively. The default value is 0
%                                (false).
%
%     Name                     - Name for the layer. The default value is
%                                "".
%   Example:
%       % Create a 1-D indexing layer.
%
%       layer = indexing1dLayer;
%
%   See also nnet.cnn.layer.Indexing1DLayer.
%
%   <a href="matlab:helpview('deeplearning','list_of_layers')">List of Deep Learning Layers</a>

%   Copyright 2022-2023 The MathWorks, Inc.

arguments
    index = "first";
    nameValueArgs.Name {iAssertValidLayerName} = '';
    nameValueArgs.HasPaddingMaskInput (1,1) logical = false;
end
index = validatestring(index,["first","last"],"indexing1dLayer","index");

nameValueArgs.Name = convertStringsToChars(nameValueArgs.Name);

layer = nnet.cnn.layer.Indexing1DLayer(nameValueArgs.Name,...
	Index = index,...
	HasPaddingMaskInput = nameValueArgs.HasPaddingMaskInput);

end

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