class_docstr: Класс, реализующий взвешенный конечный преобразователь,
  осуществляющий замены из заданного списка операций
  
  Аргументы:
  ----------
  alphabet : list
      алфавит
  
  operation_costs : dict or None(optional, default=None)
      словарь вида {(up,low) : cost}
  
  allow_spaces : bool(optional, default=False)
      разрешены ли элементы трансдукции, содержащие пробел
      (используется только если явно не заданы operation costs
      и они равны значению по умолчанию)
class_docstr_tok: ["\u041a\u043b\u0430\u0441\u0441",",","\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439","\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u044b\u0439","\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439","\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c",",","\u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e\u0449\u0438\u0439","\u0437\u0430\u043c\u0435\u043d\u044b","\u0438\u0437","\u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e","\u0441\u043f\u0438\u0441\u043a\u0430","\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439","\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b",":","--","--","--","--","--","alphabet",":","list","\u0430\u043b\u0444\u0430\u0432\u0438\u0442","operation_costs",":","dict","or","None","(","optional",",","default=None",")","\u0441\u043b\u043e\u0432\u0430\u0440\u044c","\u0432\u0438\u0434\u0430","{","(","up",",","low",")",":","cost","}","allow_spaces",":","bool","(","optional",",","default=False",")","\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u044b","\u043b\u0438","\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b","\u0442\u0440\u0430\u043d\u0441\u0434\u0443\u043a\u0446\u0438\u0438",",","\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435","\u043f\u0440\u043e\u0431\u0435\u043b","(","\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f","\u0442\u043e\u043b\u044c\u043a\u043e","\u0435\u0441\u043b\u0438","\u044f\u0432\u043d\u043e","\u043d\u0435","\u0437\u0430\u0434\u0430\u043d\u044b","operation","costs","\u0438","\u043e\u043d\u0438","\u0440\u0430\u0432\u043d\u044b","\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e","\u043f\u043e","\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e",")"]
docstr: Восстанавливает трансдукции по таблице обратных ссылок
  
  Аргументы:
  ----------
  first, second : string
      верхние и нижние элементы трансдукции
  backtraces : array-like, dtype=list, shape=(len(first)+1, len(second)+1)
      таблица обратных ссылок
  threshold : float
      порог для отсева трансдукций,
      возвращаются только трансдукции стоимостью <= threshold
  return_cost : bool (optional, default=False)
      если True, то вместе с трансдукциями возвращается их стоимость
  
  Возвращает:
  -----------
  result : list
      список вида [(трансдукция, стоимость)], если return_cost=True
      и вида [трансдукция], если return_cost=False,
      содержащий все трансдукции, переводящие first в second,
      чья стоимость не превышает threshold
docstr_tok: ["\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442","\u0442\u0440\u0430\u043d\u0441\u0434\u0443\u043a\u0446\u0438\u0438","\u043f\u043e","\u0442\u0430\u0431\u043b\u0438\u0446\u0435","\u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445","\u0441\u0441\u044b\u043b\u043e\u043a","\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b",":","--","--","--","--","--","first",",","second",":","string","\u0432\u0435\u0440\u0445\u043d\u0438\u0435","\u0438","\u043d\u0438\u0436\u043d\u0438\u0435","\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b","\u0442\u0440\u0430\u043d\u0441\u0434\u0443\u043a\u0446\u0438\u0438","backtraces",":","array-like",",","dtype=list",",","shape=","(","len","(","first",")","+1",",","len","(","second",")","+1",")","\u0442\u0430\u0431\u043b\u0438\u0446\u0430","\u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445","\u0441\u0441\u044b\u043b\u043e\u043a","threshold",":","float","\u043f\u043e\u0440\u043e\u0433","\u0434\u043b\u044f","\u043e\u0442\u0441\u0435\u0432\u0430","\u0442\u0440\u0430\u043d\u0441\u0434\u0443\u043a\u0446\u0438\u0439",",","\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f","\u0442\u043e\u043b\u044c\u043a\u043e","\u0442\u0440\u0430\u043d\u0441\u0434\u0443\u043a\u0446\u0438\u0438","\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e","<","=","threshold","return_cost",":","bool","(","optional",",","default=False",")","\u0435\u0441\u043b\u0438","True",",","\u0442\u043e","\u0432\u043c\u0435\u0441\u0442\u0435","\u0441","\u0442\u0440\u0430\u043d\u0441\u0434\u0443\u043a\u0446\u0438\u044f\u043c\u0438","\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f","\u0438\u0445","\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c","\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442",":","--","--","--","--","--","-","result",":","list","\u0441\u043f\u0438\u0441\u043e\u043a","\u0432\u0438\u0434\u0430","[","(","\u0442\u0440\u0430\u043d\u0441\u0434\u0443\u043a\u0446\u0438\u044f",",","\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c",")","]",",","\u0435\u0441\u043b\u0438","return_cost=True","\u0438","\u0432\u0438\u0434\u0430","[","\u0442\u0440\u0430\u043d\u0441\u0434\u0443\u043a\u0446\u0438\u044f","]",",","\u0435\u0441\u043b\u0438","return_cost=False",",","\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439","\u0432\u0441\u0435","\u0442\u0440\u0430\u043d\u0441\u0434\u0443\u043a\u0446\u0438\u0438",",","\u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044f\u0449\u0438\u0435","first","\u0432","second",",","\u0447\u044c\u044f","\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c","\u043d\u0435","\u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442","threshold"]
code: def _backtraces_to_transductions(
      self, first, second, backtraces, threshold, return_cost=False
  ):
      """
      Восстанавливает трансдукции по таблице обратных ссылок
  
      Аргументы:
      ----------
      first, second : string
          верхние и нижние элементы трансдукции
      backtraces : array-like, dtype=list, shape=(len(first)+1, len(second)+1)
          таблица обратных ссылок
      threshold : float
          порог для отсева трансдукций,
          возвращаются только трансдукции стоимостью <= threshold
      return_cost : bool (optional, default=False)
          если True, то вместе с трансдукциями возвращается их стоимость
  
      Возвращает:
      -----------
      result : list
          список вида [(трансдукция, стоимость)], если return_cost=True
          и вида [трансдукция], если return_cost=False,
          содержащий все трансдукции, переводящие first в second,
          чья стоимость не превышает threshold
      """
      m, n = len(first), len(second)
      agenda = [None] * (m + 1)
      for i in range(m + 1):
          agenda[i] = [[] for j in range(n + 1)]
      agenda[m][n] = [((), 0.0)]
      for i_right in range(m, -1, -1):
          for j_right in range(n, -1, -1):
              current_agenda = agenda[i_right][j_right]
              if len(current_agenda) == 0:
                  continue
              for i, j in backtraces[i_right][j_right]:
                  up, low = first[i:i_right], second[j:j_right]
                  add_cost = self.operation_costs[up][low]
                  for elem, cost in current_agenda:
                      new_cost = cost + add_cost
                      if (
                          new_cost <= threshold
                      ):  # удаление трансдукций большой стоимости
                          agenda[i][j].append(
                              (((up, low),) + elem, new_cost)
                          )
      if return_cost:
          return agenda[0][0]
      else:
          return [elem[0] for elem in agenda[0][0]]
  
imports: import copy
  import itertools
  import numpy
  from sortedcontainers import SortedListWithKey
  from .tabled_trie import Trie, make_trie
label_desc: Use image node_id 13 for calling the SegmentTransducer obj's underlying member method code with example usage: obj._backtraces_to_transductions(first, second, backtraces, threshold, return_cost) and returns: agenda, unknown