class_docstr: Token Classification Model with BERT, applicable for tasks such as Named Entity Recognition
class_docstr_tok: ["Token","Classification","Model","with","BERT",",","applicable","for","tasks","such","as","Named","Entity","Recognition"]
docstr: Get prediction for the queries
  Args:
      queries: text sequences
      batch_size: batch size to use during inference.
  Returns:
      all_preds: model predictions
docstr_tok: ["Get","prediction","for","the","queries","Args",":","queries",":","text","sequences","batch_size",":","batch","size","to","use","during","inference",".","Returns",":","all_preds",":","model","predictions"]
code: def _infer(
      self, queries: List[str], batch_size: int = None
  ) -> List[int]:
      """
      Get prediction for the queries
      Args:
          queries: text sequences
          batch_size: batch size to use during inference.
      Returns:
          all_preds: model predictions
      """
      # store predictions for all queries in a single list
      all_preds = []
      mode = self.training
      try:
          device = "cuda" if torch.cuda.is_available() else "cpu"
          # Switch model to evaluation mode
          self.eval()
          self.to(device)
          infer_datalayer = self._setup_infer_dataloader(
              queries, batch_size
          )
  
          for batch in infer_datalayer:
              (
                  input_ids,
                  input_type_ids,
                  input_mask,
                  subtokens_mask,
              ) = batch
  
              logits = self.forward(
                  input_ids=input_ids.to(device),
                  token_type_ids=input_type_ids.to(device),
                  attention_mask=input_mask.to(device),
              )
  
              subtokens_mask = subtokens_mask > 0.5
              preds = tensor2list(
                  torch.argmax(logits, axis=-1)[subtokens_mask]
              )
              all_preds.extend(preds)
      finally:
          # set mode back to its original value
          self.train(mode=mode)
      return all_preds
  
imports: import os
  from typing import List, Optional, Union
  import torch
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from torch.utils.data import DataLoader
  from nemo.collections.common.losses import CrossEntropyLoss
  from nemo.collections.nlp.data.data_utils.data_preprocessing import get_labels_to_labels_id_mapping
  from nemo.collections.nlp.data.token_classification.token_classification_dataset import BertTokenClassificationDataset, BertTokenClassificationInferDataset
  from nemo.collections.nlp.data.token_classification.token_classification_utils import get_label_ids
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport
  from nemo.collections.nlp.models.nlp_model import NLPModel
  from nemo.collections.nlp.modules.common import TokenClassifier
  from nemo.collections.nlp.parts.utils_funcs import get_classification_report, plot_confusion_matrix, tensor2list
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.utils import logging
label_desc: Use image node_id 15 for calling the TokenClassificationModel obj's underlying member method code with example usage: obj._infer(queries, batch_size) and returns: all_preds