def _saliency_map(self, a, image, target, labels, mask, fast=False):
<EOL>alphas = a.gradient(image, target) * mask<EOL>if fast:<EOL><INDENT>betas = -np.ones_like(alphas)<EOL><DEDENT>else:<EOL><INDENT>betas = np.sum([<EOL>a.gradient(image, label) * mask - alphas<EOL>for label in labels], <NUM_LIT:0>)<EOL><DEDENT>salmap = np.abs(alphas) * np.abs(betas) * np.sign(alphas * betas)<EOL>idx = np.argmin(salmap)<EOL>idx = np.unravel_index(idx, mask.shape)<EOL>pix_sign = np.sign(alphas)[idx]<EOL>return idx, pix_sign<EOL>
Implements Algorithm 3 in manuscript