code: def generate(self, data_list, **kwargs):
      model_inputs, other_info = self._process_list(data_list)
      with torch.inference_mode():
          result_ids = self._decode(model_inputs, other_info, **kwargs)
      for sent_id, result in enumerate(result_ids):
          ans_result_map: Dict[int, List[int]] = {}
          for raw_word_id, ans_id in result:
              if ans_id not in ans_result_map:
                  ans_result_map[ans_id] = []
              ans_result_map[ans_id].append(raw_word_id)
  
          answer_placeholders = other_info[sent_id][
              "answer_placeholders"
          ]
          ext_table = other_info[sent_id]["ext_table"]
          data = data_list[sent_id]
          for ans_id, token_ids in ans_result_map.items():
              if token_ids[-1] == self.tokenizer.eos_id:
                  token_ids = token_ids[:-1]
              text = self.tokenizer.decode(token_ids, ext_table)
              path = answer_placeholders[ans_id - 1]
  
              if len(path) > 0:
                  p = data["<ans>"]
                  for part in path[:-1]:
                      p = p[part]
                  p[path[-1]] = text
              else:
                  data["<ans>"] = text
          for ans_id in range(len(answer_placeholders)):
              if (ans_id + 1) not in ans_result_map:
                  path = answer_placeholders[ans_id]
                  p = data["<ans>"]
                  for part in path[:-1]:
                      p = p[part]
                  p[path[-1]] = None
      return data_list
  
file_path: DeepKE/example/llm/CPM-Bee/src/cpm_live/generation/bee.py
imports: from typing import Any, Dict, List, Tuple
  import numpy
  import torch
  import torch.nn.functional
  from .generation_utils import BeamHypotheses, apply_repetition_penalty
  from ..tokenizers.bee import CPMBeeTokenizer
  from ..models.bee import CPMBee
  from ..training_tasks.bee.pretrain import convert_data_to_id
  from ..utils import pad
label_desc: Use image node_id 4 for calling the CPMBeeGeneration obj's underlying member method code with example usage: obj.generate(data_list) and returns: data_list