class_docstr: BERT-based tagging model for ITN, inspired by LaserTagger approach.
  It maps spoken-domain input words to tags:
      KEEP, DELETE, or any of predefined replacement tags which correspond to a written-domain fragment.
  Example: one hundred thirty four -> _1 <DELETE> 3 4_
class_docstr_tok: ["BERT-based","tagging","model","for","ITN",",","inspired","by","LaserTagger","approach",".","It","maps","spoken-domain","input","words","to","tags",":","KEEP",",","DELETE",",","or","any","of","predefined","replacement","tags","which","correspond","to","a","written-domain","fragment",".","Example",":","one","hundred","thirty","four","-",">","_1","<","DELETE",">","3","4_"]
docstr: Main function for Inference
  
  Args:
      sents: A list of input sentences (lowercase spoken-domain words separated by space).
  
  Returns:
      all_preds: A list of tab-separated text records, same size as input list. Each record consists of 4 items:
          - final output text
          - input words
          - tags predicted for input words
          - tags after swap preprocessing
          - semiotic labels predicted for input words
docstr_tok: ["Main","function","for","Inference","Args",":","sents",":","A","list","of","input","sentences","(","lowercase","spoken-domain","words","separated","by","space",")",".","Returns",":","all_preds",":","A","list","of","tab-separated","text","records",",","same","size","as","input","list",".","Each","record","consists","of","4","items",":","-","final","output","text","-","input","words","-","tags","predicted","for","input","words","-","tags","after","swap","preprocessing","-","semiotic","labels","predicted","for","input","words"]
code: def _infer(self, sents: List[str]) -> List[List[int]]:
      """Main function for Inference
  
      Args:
          sents: A list of input sentences (lowercase spoken-domain words separated by space).
  
      Returns:
          all_preds: A list of tab-separated text records, same size as input list. Each record consists of 4 items:
              - final output text
              - input words
              - tags predicted for input words
              - tags after swap preprocessing
              - semiotic labels predicted for input words
      """
  
      # all input sentences go into one batch
      dataloader_cfg = {
          "batch_size": len(sents),
          "num_workers": 3,
          "pin_memory": False,
      }
      infer_datalayer = self._setup_infer_dataloader(
          dataloader_cfg, sents
      )
  
      batch = next(iter(infer_datalayer))
      input_ids, input_mask, segment_ids = batch
  
      tag_logits, semiotic_logits = self.forward(
          input_ids=input_ids.to(self.device),
          input_mask=input_mask.to(self.device),
          segment_ids=segment_ids.to(self.device),
      )
  
      all_preds = []
      for i, sent in enumerate(sents):
          example = self.builder.build_bert_example(
              source=sent, infer=True
          )
          tag_preds = tensor2list(torch.argmax(tag_logits[i], dim=-1))
          semiotic_preds = tensor2list(
              torch.argmax(semiotic_logits[i], dim=-1)
          )
  
          # this mask is required by get_token_labels
          example.features["labels_mask"] = (
              [0] + [1] * (len(semiotic_preds) - 2) + [0]
          )
          example.features["tag_labels"] = tag_preds
          example.features["semiotic_labels"] = semiotic_preds
          tags = [
              self.id_2_tag[label_id]
              for label_id in example.get_token_labels("tag_labels")
          ]
          semiotic_labels = [
              self.id_2_semiotic[label_id]
              for label_id in example.get_token_labels(
                  "semiotic_labels"
              )
          ]
  
          (
              prediction,
              inp_str,
              tag_str,
              tag_with_swap_str,
          ) = example.editing_task.realize_output(tags, semiotic_labels)
          all_preds.append(
              prediction
              + "\t"
              + inp_str
              + "\t"
              + tag_str
              + "\t"
              + tag_with_swap_str
              + "\t"
              + " ".join(semiotic_labels)
          )
  
      return all_preds
  
imports: from time import perf_counter
  from typing import Dict, List, Optional
  import torch
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from nemo.collections.common.losses import CrossEntropyLoss
  from nemo.collections.nlp.data.text_normalization_as_tagging import ThutmoseTaggerDataset, ThutmoseTaggerTestDataset, bert_example, tagging
  from nemo.collections.nlp.data.text_normalization_as_tagging.utils import read_label_map, read_semiotic_classes
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport
  from nemo.collections.nlp.models.nlp_model import NLPModel
  from nemo.collections.nlp.modules.common.token_classifier import TokenClassifier
  from nemo.collections.nlp.parts.utils_funcs import tensor2list
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.neural_types import LogitsType, NeuralType
  from nemo.utils import logging
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 11 for calling the ThutmoseTaggerModel obj's underlying member method code with example usage: obj._infer(sents) and returns: all_preds