function d = getDistributedFromSpmd(userData)
%getDistributedFromSpmd Helper for codistributed.getRemoteFromSPMD

% Copyright 2018-2022 The MathWorks, Inc.

ud = userData{1}; % Should be replicated, so pick the user data from worker 1.
bb = 0;
for ii=1:length( userData )
    bb = bb + userData{ii}{end};
end
% Use the "undoc" flag to allow us to build the distributed with these arguments.
d = distributed( ud{1:end-1}, bb, 'undoc:distributedFromSPMD' );
end
