class_docstr: Class for query generation using Wikidata hdt file
class_docstr_tok: ["Class","for","query","generation","using","Wikidata","hdt","file"]
code: def __call__(
      self,
      question_batch: List[str],
      question_san_batch: List[str],
      template_type_batch: Union[List[List[str]], List[str]],
      entities_from_ner_batch: List[List[str]],
      types_from_ner_batch: List[List[str]],
      entity_tags_batch: List[List[str]],
      probas_batch: List[List[float]],
      answer_types_batch: List[Set[str]] = None,
      entities_to_link_batch: List[List[int]] = None,
  ) -> Tuple[List[Any], List[Any]]:
      candidate_outputs_batch, template_answers_batch = [], []
      if not answer_types_batch or answer_types_batch[0] is None:
          answer_types_batch = [[] for _ in question_batch]
      if (
          not entities_to_link_batch
          or entities_to_link_batch[0] is None
      ):
          entities_to_link_batch = [
              [1 for _ in substr_list]
              for substr_list in entities_from_ner_batch
          ]
      log.debug(
          f"kbqa inputs {question_batch} {question_san_batch} template_type_batch: {template_type_batch} --- "
          f"entities_from_ner: {entities_from_ner_batch} --- types_from_ner: {types_from_ner_batch} --- "
          f"entity_tags_batch: {entity_tags_batch} --- answer_types_batch: "
          f"{[list(elem)[:3] for elem in answer_types_batch]}"
      )
      for (
          question,
          question_sanitized,
          template_type,
          entities_from_ner,
          types_from_ner,
          entity_tags_list,
          probas,
          entities_to_link,
          answer_types,
      ) in zip(
          question_batch,
          question_san_batch,
          template_type_batch,
          entities_from_ner_batch,
          types_from_ner_batch,
          entity_tags_batch,
          probas_batch,
          entities_to_link_batch,
          answer_types_batch,
      ):
          if template_type == "-1":
              template_type = "7"
          (
              candidate_outputs,
              template_answer,
          ) = self.find_candidate_answers(
              question,
              question_sanitized,
              template_type,
              entities_from_ner,
              types_from_ner,
              entity_tags_list,
              probas,
              entities_to_link,
              answer_types,
          )
          candidate_outputs_batch.append(candidate_outputs)
          template_answers_batch.append(template_answer)
  
      if self.return_answers:
          answers = self.rel_ranker(
              question_batch,
              template_type_batch,
              candidate_outputs_batch,
              entities_from_ner_batch,
              template_answers_batch,
          )
          log.debug(f"(__call__)answers: {answers}")
          if not answers:
              answers = ["Not Found" for _ in question_batch]
          return answers
      else:
          return candidate_outputs_batch, template_answers_batch
  
imports: import copy
  import itertools
  import re
  from collections import defaultdict
  from logging import getLogger
  from typing import Tuple, List, Optional, Union, Dict, Any, Set
  import nltk
  import numpy
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.component import Component
  from deeppavlov.models.kbqa.query_generator_base import QueryGeneratorBase
  from deeppavlov.models.kbqa.rel_ranking_infer import RelRankerInfer
  from deeppavlov.models.kbqa.utils import extract_year, extract_number, make_combs, fill_query, find_query_features, make_sparql_query, merge_sparql_query
  from deeppavlov.models.kbqa.wiki_parser import WikiParser
label_desc: Use image node_id 2 for calling the QueryGenerator obj's underlying member method code with example usage: obj.__call__(question_batch, question_san_batch, template_type_batch, entities_from_ner_batch, types_from_ner_batch, entity_tags_batch, probas_batch, answer_types_batch, entities_to_link_batch) and returns: answers, candidate_outputs_batch,  template_answers_batch