docstr: Get prediction for the queries (intent and slots)
  
  
  Args:
      queries: text sequences
      test_ds: Dataset configuration section.
      threshold: Threshold for rounding prediction logits
  
  Returns:
      predicted_intents: model intent predictions with their probabilities
          Example:  [[('flight', 0.84)], [('airfare', 0.54), 
                      ('flight', 0.73), ('meal', 0.24)]]
      predicted_slots: model slot predictions
          Example:  ['O B-depart_date.month_name B-depart_date.day_number',
                     'O O B-flight_stop O O O']
  
      predicted_vector: model intent predictions for each individual query. Binary values within each list 
          indicate whether a class is prediced for the given query (1 for True, 0 for False)
          Example: [[1,0,0,0,0,0], [0,0,1,0,0,0]]
docstr_tok: ["Get","prediction","for","the","queries","(","intent","and","slots",")","Args",":","queries",":","text","sequences","test_ds",":","Dataset","configuration","section",".","threshold",":","Threshold","for","rounding","prediction","logits","Returns",":","predicted_intents",":","model","intent","predictions","with","their","probabilities","Example",":","[","[","(","'flight","'",",","0.84",")","]",",","[","(","'airfare","'",",","0.54",")",",","(","'flight","'",",","0.73",")",",","(","'meal","'",",","0.24",")","]","]","predicted_slots",":","model","slot","predictions","Example",":","[","'","O","B-depart_date.month_name","B-depart_date.day_number","'",",","'","O","O","B-flight_stop","O","O","O","'","]","predicted_vector",":","model","intent","predictions","for","each","individual","query",".","Binary","values","within","each","list","indicate","whether","a","class","is","prediced","for","the","given","query","(","1","for","True",",","0","for","False",")","Example",":","[","[","1,0,0,0,0,0","]",",","[","0,0,1,0,0,0","]","]"]
code: def predict_from_examples(
      self,
      queries: List[str],
      test_ds: DictConfig,
      threshold: float = None,
  ) -> Tuple[List[List[Tuple[str, float]]], List[str], List[List[int]]]:
      """
      Get prediction for the queries (intent and slots)
  
  
      Args:
          queries: text sequences
          test_ds: Dataset configuration section.
          threshold: Threshold for rounding prediction logits
  
      Returns:
          predicted_intents: model intent predictions with their probabilities
              Example:  [[('flight', 0.84)], [('airfare', 0.54),
                          ('flight', 0.73), ('meal', 0.24)]]
          predicted_slots: model slot predictions
              Example:  ['O B-depart_date.month_name B-depart_date.day_number',
                         'O O B-flight_stop O O O']
  
          predicted_vector: model intent predictions for each individual query. Binary values within each list
              indicate whether a class is prediced for the given query (1 for True, 0 for False)
              Example: [[1,0,0,0,0,0], [0,0,1,0,0,0]]
      """
      predicted_intents = []
  
      if threshold is None:
          threshold = self.threshold
      logging.info(f"Using threshold = {threshold}")
  
      predicted_slots = []
      predicted_vector = []
  
      mode = self.training
      try:
          device = "cuda" if torch.cuda.is_available() else "cpu"
  
          # Retrieve intent and slot vocabularies from configuration.
          intent_labels = self.cfg.data_desc.intent_labels
          slot_labels = self.cfg.data_desc.slot_labels
  
          # Switch model to evaluation mode
          self.eval()
          self.to(device)
  
          # Dataset.
          infer_datalayer = self._setup_infer_dataloader(
              queries, test_ds
          )
  
          for batch in infer_datalayer:
              (
                  input_ids,
                  input_type_ids,
                  input_mask,
                  loss_mask,
                  subtokens_mask,
              ) = batch
  
              intent_logits, slot_logits = self.forward(
                  input_ids=input_ids.to(device),
                  token_type_ids=input_type_ids.to(device),
                  attention_mask=input_mask.to(device),
              )
  
              # predict intents and slots for these examples
              # intents
              intent_preds = tensor2list(torch.sigmoid(intent_logits))
              # convert numerical outputs to Intent and Slot labels from the dictionaries
              for intents in intent_preds:
                  intent_lst = []
                  temp_list = []
                  for intent_num, probability in enumerate(intents):
                      if probability >= threshold:
                          intent_lst.append(
                              (
                                  intent_labels[int(intent_num)],
                                  round(probability, 2),
                              )
                          )
                          temp_list.append(1)
                      else:
                          temp_list.append(0)
  
                  predicted_vector.append(temp_list)
                  predicted_intents.append(intent_lst)
  
              # slots
              slot_preds = torch.argmax(slot_logits, axis=-1)
              temp_slots_preds = []
  
              for slot_preds_query, mask_query in zip(
                  slot_preds, subtokens_mask
              ):
                  temp_slots = ""
                  query_slots = ""
                  for slot, mask in zip(slot_preds_query, mask_query):
                      if mask == 1:
                          if slot < len(slot_labels):
                              query_slots += (
                                  slot_labels[int(slot)] + " "
                              )
                              temp_slots += f"{slot} "
                          else:
                              query_slots += "Unknown_slot "
                              temp_slots += "0 "
                  predicted_slots.append(query_slots.strip())
                  temp_slots_preds.append(temp_slots)
  
      finally:
          # set mode back to its original value
          self.train(mode=mode)
  
      return predicted_intents, predicted_slots, predicted_vector
  
imports: import os
  from typing import List, Optional, Tuple
  import numpy
  import numpy.typing
  import torch
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from sklearn.metrics import f1_score, precision_score, recall_score
  from torch.utils.data import DataLoader
  from nemo.collections.common.losses import AggregatorLoss, BCEWithLogitsLoss, CrossEntropyLoss
  from nemo.collections.nlp.data.intent_slot_classification import MultiLabelIntentSlotClassificationDataset, MultiLabelIntentSlotDataDesc
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport, MultiLabelClassificationReport
  from nemo.collections.nlp.models.intent_slot_classification import IntentSlotClassificationModel
  from nemo.collections.nlp.modules.common import SequenceTokenClassifier
  from nemo.collections.nlp.parts.utils_funcs import tensor2list
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging
label_desc: Use image node_id 8 for calling the MultiLabelIntentSlotClassificationModel obj's underlying member method code with example usage: obj.predict_from_examples(queries, test_ds, threshold) and returns: predicted_intents,  predicted_slots,  predicted_vector