function X = internal_groupnorm(X, offset, scale, numGroups, epsilon, channelDim)
% This function is undocumented and will change in a future release.

%   Y = internal_groupnorm(X, offset, scale, numGroups, epsilon, channelDim)
%   Compute the group normalization in training or inference modes.
%
%   Inputs:
%     X               Batch data.
%                     numeric array
%     numGroups       Number of groups.
%                     positive integer
%     offset          Offset. Also called beta. Shape is only non-trivial in channel dimension.
%                     numeric array
%     scale           Scale. Also called gamma. Shape is only non-trivial in channel dimension.
%                     numeric array
%     epsilon         Constant to avoid division by zero.
%                     numeric scalar
%     channelDim      Channel dimension.
%                     double
%  
%   Outputs:
%     Y               Normalized output. Shape is only non-trivial in channel dimension.
%                     numeric array

%   Copyright 2020-2021 The MathWorks, Inc.

if ~isreal(X) || ~isreal(offset) || ~isreal(scale)
    error(message('deep:dlarray:ComplexNotSupported'))
end

X = nnet.internal.cnnhost.groupNormalizationForward(X,offset,scale,epsilon,channelDim,numGroups);

end

