def _decode_anno()

in src/chug/doc/doc_vqa_processor.py [0:0]


    def _decode_anno(self, sample) -> Tuple[Dict, List[int], int]:
        if self.multi_qa_key:
            # FIXME multi qa expansion is a WIP
            qa_list = sample[self.multi_qa_key]
            assert isinstance(qa_list, (list, tuple)), f'Expected a list or tuple, got {type(qa_list)}.'
            assert False, 'WIP'
        else:
            question = _get_value(self.question_key, sample)
            question_id = _get_value(self.question_id_key, sample)
            answers = _get_value(self.answer_key, sample)

            if answers is not None and self.text_target_feat is not None:
                answer = random.choice(answers)
            else:
                answer = None

            input_text = self.question_prefix + question + self.question_suffix + self.answer_prefix
            if answer is not None:
                input_text += answer + self.answer_suffix

            output = {
                self.text_input_name: input_text,
                '_parse': {
                    'question_id': question_id,
                    'question': question,
                    'answers': answers,  # list, all answers included in parse
                }
            }

            if self.text_process_fn is not None:
                processed = self.text_process_fn(input_text)
                assert self.text_input_name in processed, \
                    f"Text input name '{self.text_input_name}' not found in processed sample."
                if self.text_target_feat is not None:
                    assert self.text_target_name in processed, f"Expected a text target named '{self.text_target_name}' in processed sample."
                output.update(processed)
            else:
                output[self.text_input_name] = input_text

            return output, [0], 1