code: def correct_variables(
      query_triplets: List[str],
      answer_ent: List[str],
      query_info: Dict[str, str],
  ):
      for i in range(len(query_triplets)):
          for ent_var in answer_ent:
              triplet_elements = query_triplets[i].split()
              for j in range(len(triplet_elements)):
                  if triplet_elements[
                      j
                  ] not in ent_var and triplet_elements[j].startswith(
                      "?"
                  ):
                      triplet_elements[j] = query_info["mid_var"]
                      break
                  if triplet_elements[j].startswith(
                      "?"
                  ) and triplet_elements[j] not in [
                      query_info["mid_var"],
                      query_info["unk_var"],
                  ]:
                      triplet_elements[j] = query_info["unk_var"]
                      break
              query_triplets[i] = " ".join(triplet_elements)
              query_triplets[i] = query_triplets[i].replace(
                  ent_var, query_info["unk_var"]
              )
      return query_triplets
  
file_path: DeepPavlov/deeppavlov/models/kbqa/utils.py
imports: import itertools
  import re
  from collections import namedtuple
  from typing import List, Tuple, Dict, Any
label_desc: Use image node_id 7 for calling a global function with example usage: correct_variables(query_triplets, answer_ent, query_info) and returns: query_triplets