class_docstr: This class takes as input entity substrings, defines the template of the query and
  fills the slots of the template with candidate entities and relations.
class_docstr_tok: ["This","class","takes","as","input","entity","substrings",",","defines","the","template","of","the","query","and","fills","the","slots","of","the","template","with","candidate","entities","and","relations","."]
code: def find_candidate_answers(
      self,
      question: str,
      question_sanitized: str,
      template_types: Union[List[str], str],
      entities_from_ner: List[str],
      types_from_ner: List[str],
      entity_tags: List[str],
      probas: List[float],
      entities_to_link: List[int],
      answer_types: Set[str],
  ) -> Tuple[Union[List[Dict[str, Any]], list], str]:
      candidate_outputs = []
      self.template_nums = [template_types]
  
      replace_tokens = [
          (" - ", "-"),
          (" .", ""),
          ("{", ""),
          ("}", ""),
          ("  ", " "),
          ('"', "'"),
          ("(", ""),
          (")", ""),
          ("–", "-"),
      ]
      for old, new in replace_tokens:
          question = question.replace(old, new)
  
      (
          entities_from_template,
          types_from_template,
          rels_from_template,
          rel_dirs_from_template,
          query_type_template,
          entity_types,
          template_answer,
          template_answer_types,
          template_found,
      ) = self.template_matcher(question_sanitized, entities_from_ner)
      if query_type_template:
          self.template_nums = [query_type_template]
  
      log.debug(
          f"question: {question} entities_from_template {entities_from_template} template_type {self.template_nums} "
          f"types from template {types_from_template} rels_from_template {rels_from_template} entities_from_ner "
          f"{entities_from_ner} types_from_ner {types_from_ner} answer_types {list(answer_types)[:3]}"
      )
  
      if entities_from_template or types_from_template:
          if rels_from_template[0][0] == "PHOW":
              how_to_content = self.find_answer_wikihow(
                  entities_from_template[0]
              )
              candidate_outputs = [["PHOW", how_to_content, 1.0]]
          else:
              entity_ids = self.get_entity_ids(
                  entities_from_template,
                  entity_tags,
                  probas,
                  question,
                  entities_to_link,
              )
              type_ids = self.get_entity_ids(
                  types_from_template,
                  ["t" for _ in types_from_template],
                  [1.0 for _ in types_from_template],
                  question,
              )
              log.debug(
                  f"entities_from_template: {entities_from_template} --- entity_types: {entity_types} --- "
                  f"types_from_template: {types_from_template} --- rels_from_template: {rels_from_template} "
                  f"--- answer_types: {template_answer_types} --- entity_ids: {entity_ids}"
              )
              candidate_outputs = self.sparql_template_parser(
                  question_sanitized,
                  entity_ids,
                  type_ids,
                  template_answer_types,
                  rels_from_template,
                  rel_dirs_from_template,
              )
      if not candidate_outputs and (
          entities_from_ner or types_from_ner
      ):
          log.debug(f"(__call__)entities_from_ner: {entities_from_ner}")
          entity_ids = self.get_entity_ids(
              entities_from_ner, entity_tags, probas, question
          )
          type_ids = self.get_entity_ids(
              types_from_ner,
              ["t" for _ in types_from_ner],
              [1.0 for _ in types_from_ner],
              question,
          )
          log.debug(
              f"(__call__)entity_ids: {entity_ids} type_ids {type_ids}"
          )
          self.template_nums = template_types
          log.debug(
              f"(__call__)self.template_nums: {self.template_nums}"
          )
          if not self.syntax_structure_known:
              entity_ids = entity_ids[:3]
          candidate_outputs = self.sparql_template_parser(
              question_sanitized, entity_ids, type_ids, answer_types
          )
      return candidate_outputs, template_answer
  
imports: import itertools
  import json
  from logging import getLogger
  from typing import Tuple, List, Dict, Optional, Union, Any, Set
  from bs4 import BeautifulSoup
  from whapi import search, get_html
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.file import read_json
  from deeppavlov.core.models.component import Component
  from deeppavlov.core.models.serializable import Serializable
  from deeppavlov.models.entity_extraction.entity_linking import EntityLinker
  from deeppavlov.models.kbqa.rel_ranking_infer import RelRankerInfer
  from deeppavlov.models.kbqa.template_matcher import TemplateMatcher
  from deeppavlov.models.kbqa.utils import preprocess_template_queries
label_desc: Use image node_id 4 for calling the QueryGeneratorBase obj's underlying member method code with example usage: obj.find_candidate_answers(question, question_sanitized, template_types, entities_from_ner, types_from_ner, entity_tags, probas, entities_to_link, answer_types) and returns: candidate_outputs,  template_answer