docstr: Using the traced model, create a ScriptModule which has a nicer API that
  includes generating tensors from simple data types, and returns classified
  values according to the output layer (eg. as a dict mapping class name to score)
docstr_tok: ["Using","the","traced","model",",","create","a","ScriptModule","which","has","a","nicer","API","that","includes","generating","tensors","from","simple","data","types",",","and","returns","classified","values","according","to","the","output","layer","(","eg",".","as","a","dict","mapping","class","name","to","score",")"]
code: def torchscriptify(self, tensorizers, traced_model):
      """Using the traced model, create a ScriptModule which has a nicer API that
      includes generating tensors from simple data types, and returns classified
      values according to the output layer (eg. as a dict mapping class name to score)
      """
      script_tensorizer = tensorizers["tokens"].torchscriptify()
      if self.encoder.export_encoder:
          return ScriptPyTextEmbeddingModuleIndex(
              traced_model, script_tensorizer, index=0
          )
      else:
          if "dense" in tensorizers:
              return ScriptPyTextModuleWithDense(
                  model=traced_model,
                  output_layer=self.output_layer.torchscript_predictions(),
                  tensorizer=script_tensorizer,
                  normalizer=tensorizers["dense"].normalizer,
              )
          else:
              return ScriptPyTextModule(
                  model=traced_model,
                  output_layer=self.output_layer.torchscript_predictions(),
                  tensorizer=script_tensorizer,
              )
  
imports: import logging
  from typing import Dict, List, Optional, Tuple
  import torch
  from pytext import resources
  from pytext.common.constants import Stage, TORCH_VERSION
  from pytext.config import ConfigBase
  from pytext.data.roberta_tensorizer import RoBERTaTensorizer, RoBERTaTokenLevelTensorizer
  from pytext.data.tensorizers import FloatListTensorizer, LabelTensorizer, NumericLabelTensorizer, Tensorizer
  from pytext.models.bert_classification_models import NewBertModel
  from pytext.models.bert_regression_model import NewBertRegressionModel
  from pytext.models.decoders.mlp_decoder import MLPDecoder
  from pytext.models.model import BaseModel
  from pytext.models.module import create_module, Module
  from pytext.models.output_layers import WordTaggingOutputLayer
  from pytext.models.representations.transformer import MultiheadLinearAttention, PassthroughEncoder, PassthroughTransformer, PostEncoder, QuantizedMultiheadLinearAttention, SELFIETransformer, SentenceEncoder
  from pytext.models.representations.transformer_sentence_encoder_base import PoolingMethod, TransformerSentenceEncoderBase
  from pytext.models.utils import normalize_embeddings
  from pytext.torchscript.module import ScriptPyTextEmbeddingModuleIndex, ScriptPyTextModule, ScriptPyTextModuleWithDense
  from pytext.utils.file_io import PathManager
  from pytext.utils.usage import log_class_usage
  from pytorch.text.fb.nn.modules.multihead_attention import MultiheadSelfAttention
  from pytorch.text.fb.nn.modules.transformer import DEFAULT_MAX_SEQUENCE_LENGTH, Transformer, TransformerLayer
  from torch import nn
  from torch.serialization import default_restore_location
  from .r3f_models import R3FConfigOptions, R3FPyTextMixin
label_desc: Use image node_id 2 for calling the RoBERTa obj's underlying member method code with example usage: obj.torchscriptify(tensorizers, traced_model) and returns: ScriptPyTextEmbeddingModuleIndex, ScriptPyTextModuleWithDense, ScriptPyTextModule