def save(self, solver, out_dir, save_extra=False, id=None):
        """ Save results to a directory """
        if not id:
            id = self.input.id
        if not id:
            raise ValueError("Need an id for saving")
        if not os.path.exists(out_dir):
            os.makedirs(out_dir)
        basename = os.path.join(out_dir, str(self.input.id))

        r, s = self.get_r_s()
        r_filename = basename % '%s-r.png'
        image_util.save(r_filename, r, mask_nz=solver.input.mask_nz,
                        rescale=True)

        s_filename = '%s-s.png' % basename
        image_util.save(s_filename, s, mask_nz=solver.input.mask_nz,
                        rescale=True)

        if save_extra:
            r_gray_filename = '%s-r-gray.png' % basename
            r_gray = self.get_r_gray()
            image_util.save(r_gray_filename, r_gray,
                            mask_nz=solver.input.mask_nz, rescale=True)

            labels_filename = '%s-labels.png' % basename
            labels_image = self.get_labels_visualization()
            image_util.save(labels_filename, labels_image,
                            mask_nz=solver.input.mask_nz, rescale=True)
dataset/ETHPy150Open seanbell/intrinsic/bell2014/decomposition.py/IntrinsicDecomposition.save/swapped operands of `%`