class_docstr: Component that chooses a candidate with the highest product of base and language model probabilities
  
  Args:
       load_path: path to the kenlm model file
       beam_size: beam size for highest probability search
  
  Attributes:
      lm: kenlm object
      beam_size: beam size for highest probability search
code: def _infer_instance(self, candidates: List[List[Tuple[float, str]]]):
      candidates = candidates + [[(0, "</s>")]]
      state = kenlm.State()
      self.lm.BeginSentenceWrite(state)
      beam = [(0, state, [])]
      for sublist in candidates:
          new_beam = []
          for beam_score, beam_state, beam_words in beam:
              for score, candidate in sublist:
                  prev_state = beam_state
                  c_score = 0
                  cs = candidate.split()
                  for candidate in cs:
                      state = kenlm.State()
                      c_score += self.lm.BaseScore(
                          prev_state, candidate, state
                      )
                      prev_state = state
                  new_beam.append(
                      (
                          beam_score + score + c_score,
                          state,
                          beam_words + cs,
                      )
                  )
          new_beam.sort(reverse=True)
          beam = new_beam[: self.beam_size]
      score, state, words = beam[0]
      return words[:-1]
  
file_path: DeepPavlov/deeppavlov/models/spelling_correction/electors/kenlm_elector.py
imports: from logging import getLogger
  from pathlib import Path
  from typing import List, Tuple
  import kenlm
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.component import Component
label_desc: Use image node_id 3 for calling the KenlmElector obj's underlying member method code with example usage: obj._infer_instance(candidates) and returns: words