function dZ = internal_maxpoolBackward(dZ, X, ~, poolSize, padding, stride)
% This function is undocumented and will change in a future release.

%   Copyright 2019 The MathWorks, Inc.

% Ensure all inputs have the same data type
[dZ, X] = nnet.internal.cnnhost.castToSuperiorFloat(dZ, X);

% Reshape as [top1 top2 ... topn bot1 bot2 ... botn] to match the CPU builtin
padding = reshape(reshape(padding, 2, [])', 1, []);

% Call the builtin
dZ = builtin('_maxpoolBackward', dZ, X, poolSize, padding, stride);

end
