class_docstr: Transformers handler class for  MMFTransformerWithVideoAudio model.
class_docstr_tok: ["Transformers","handler","class","for","MMFTransformerWithVideoAudio","model","."]
docstr: Predict the class (or classes) of the received text using the serialized transformers checkpoint.
          
docstr_tok: ["Predict","the","class","(","or","classes",")","of","the","received","text","using","the","serialized","transformers","checkpoint","."]
code: def inference(self, samples):
      """Predict the class (or classes) of the received text using the serialized transformers checkpoint."""
      if torch.cuda.is_available():
          with torch.cuda.device(samples.get_device()):
              output = self.model(samples)
      else:
          output = self.model(samples)
  
      sigmoid_scores = torch.sigmoid(output["scores"])
      binary_scores = torch.round(sigmoid_scores)
      score = binary_scores[0]
      score = score.nonzero()
  
      predictions = []
      for item in score:
          predictions.append(self.idx_to_class[item.item()])
      print("************** predictions *********", predictions)
      return predictions
  
imports: import json
  import logging
  import os
  import pickle
  import sys
  import ast
  import torch
  from ts.torch_handler.base_handler import BaseHandler
  import io
  import torchaudio
  import torchvision
  from omegaconf import OmegaConf
  import pandas
  import csv
  from torchvision import transforms
  from torchvision.datasets.vision import VisionDataset
  from torchvision.io import read_video_timestamps, read_video
  from mmf.common.sample import Sample, SampleList
  from mmf.utils.env import set_seed, setup_imports
  from mmf.utils.logger import setup_logger, setup_very_basic_config
  from mmf.datasets.base_dataset import BaseDataset
  from mmf.utils.build import build_encoder, build_model, build_processors
  from mmf.datasets.mmf_dataset_builder import MMFDatasetBuilder
  from torch.utils.data import IterableDataset
  from mmf.utils.configuration import load_yaml
  from mmf.models.mmf_transformer import MMFTransformer
label_desc: Use image node_id 4 for calling the MMFHandler obj's underlying member method code with example usage: obj.inference(samples) and returns: predictions