code: def main(args):
      # Chain preprocessing steps as defined during training.
      text_transform = T.Sequential(
          T.SentencePieceTokenizer(XLMR_SPM_MODEL_PATH),
          T.VocabTransform(load_state_dict_from_url(XLMR_VOCAB_PATH)),
          T.Truncate(MAX_SEQ_LEN - 2),
          T.AddToken(token=BOS_IDX, begin=True),
          T.AddToken(token=EOS_IDX, begin=False),
      )
  
      NUM_CLASSES = 2
      INPUT_DIM = 768
  
      classifier_head = RobertaClassificationHead(
          num_classes=NUM_CLASSES, input_dim=INPUT_DIM
      )
  
      model = XLMR_BASE_ENCODER.get_model(head=classifier_head)
  
      # Load trained parameters and load them into the model
      model.load_state_dict(
          torch.load(args.input_file, map_location=torch.device("cpu"))
      )
  
      # Chain the tokenizer, the adapter and the model
      combi_model = T.Sequential(
          text_transform,
          TokenizerModelAdapter(PADDING_IDX),
          model,
      )
  
      combi_model.eval()
  
      # Make sure to move the model to CPU to avoid placement error during loading
      combi_model.to(torch.device("cpu"))
  
      combi_model_jit = torch.jit.script(combi_model)
  
      torch.jit.save(combi_model_jit, args.output_file)
  
file_path: serve/examples/text_classification_with_scriptable_tokenizer/script_tokenizer_and_model.py
imports: import argparse
  from typing import Any
  import torch
  import torchtext.functional
  import torchtext.transforms
  from torch import nn
  from torch.hub import load_state_dict_from_url
  from torchtext.models import XLMR_BASE_ENCODER, RobertaClassificationHead
label_desc: Use image node_id 1 for calling a global function with example usage: main(args) without return types