def __call__()

in build_obelics/12_02_remove_opt_out_images.py [0:0]


    def __call__(self, example):
        metadata = json.loads(example["metadata"])
        indices_to_remove = [
            ind for ind, meta in enumerate(metadata) if (meta is not None) and (meta["src"] in self.opt_out_image_urls)
        ]
        if indices_to_remove:
            example["texts"] = [el for ind, el in enumerate(example["texts"]) if ind not in indices_to_remove]
            example["images"] = [el for ind, el in enumerate(example["images"]) if ind not in indices_to_remove]
            example["metadata"] = json.dumps([el for ind, el in enumerate(metadata) if ind not in indices_to_remove])
        return example