class_docstr: DocModel that receives both word IDs and byte IDs as inputs (concatenating
  word and byte-token embeddings to represent input tokens).
class_docstr_tok: ["DocModel","that","receives","both","word","IDs","and","byte","IDs","as","inputs","(","concatenating","word","and","byte-token","embeddings","to","represent","input","tokens",")","."]
code: def torchscriptify(self, tensorizers, traced_model):
      output_layer = self.output_layer.torchscript_predictions()
      max_seq_len = tensorizers["tokens"].max_seq_len or -1
      max_byte_len = tensorizers["token_bytes"].max_byte_len
      byte_offset_for_non_padding = tensorizers[
          "token_bytes"
      ].offset_for_non_padding
      input_vocab = tensorizers["tokens"].vocab
  
      class Model(jit.ScriptModule):
          def __init__(self):
              super().__init__()
              self.vocab = ScriptVocabulary(
                  input_vocab,
                  input_vocab.get_unk_index(),
                  input_vocab.get_pad_index(),
              )
              self.max_seq_len = jit.Attribute(max_seq_len, int)
              self.max_byte_len = jit.Attribute(max_byte_len, int)
              self.byte_offset_for_non_padding = jit.Attribute(
                  byte_offset_for_non_padding, int
              )
              self.pad_idx = jit.Attribute(
                  input_vocab.get_pad_index(), int
              )
              self.model = traced_model
              self.output_layer = output_layer
  
          @jit.script_method
          def forward(
              self,
              texts: Optional[List[str]] = None,
              multi_texts: Optional[List[List[str]]] = None,
              tokens: Optional[List[List[str]]] = None,
              languages: Optional[List[str]] = None,
          ):
              if tokens is None:
                  raise RuntimeError("tokens is required")
  
              tokens = truncate_tokens(
                  tokens, self.max_seq_len, self.vocab.pad_token
              )
              seq_lens = make_sequence_lengths(tokens)
              word_ids = self.vocab.lookup_indices_2d(tokens)
              word_ids = pad_2d(word_ids, seq_lens, self.pad_idx)
              token_bytes, _ = make_byte_inputs(
                  tokens,
                  self.max_byte_len,
                  self.byte_offset_for_non_padding,
              )
              logits = self.model(
                  torch.tensor(word_ids),
                  token_bytes,
                  torch.tensor(seq_lens),
              )
              return self.output_layer(logits)
  
      class ModelWithDenseFeat(jit.ScriptModule):
          def __init__(self):
              super().__init__()
              self.vocab = ScriptVocabulary(
                  input_vocab,
                  input_vocab.get_unk_index(),
                  input_vocab.get_pad_index(),
              )
              self.normalizer = tensorizers["dense"].normalizer
              self.max_seq_len = jit.Attribute(max_seq_len, int)
              self.max_byte_len = jit.Attribute(max_byte_len, int)
              self.byte_offset_for_non_padding = jit.Attribute(
                  byte_offset_for_non_padding, int
              )
              self.pad_idx = jit.Attribute(
                  input_vocab.get_pad_index(), int
              )
              self.model = traced_model
              self.output_layer = output_layer
  
          @jit.script_method
          def forward(
              self,
              texts: Optional[List[str]] = None,
              multi_texts: Optional[List[List[str]]] = None,
              tokens: Optional[List[List[str]]] = None,
              languages: Optional[List[str]] = None,
              dense_feat: Optional[List[List[float]]] = None,
          ):
              if tokens is None:
                  raise RuntimeError("tokens is required")
              if dense_feat is None:
                  raise RuntimeError("dense_feat is required")
  
              tokens = truncate_tokens(
                  tokens, self.max_seq_len, self.vocab.pad_token
              )
              seq_lens = make_sequence_lengths(tokens)
              word_ids = self.vocab.lookup_indices_2d(tokens)
              word_ids = pad_2d(word_ids, seq_lens, self.pad_idx)
              token_bytes, _ = make_byte_inputs(
                  tokens,
                  self.max_byte_len,
                  self.byte_offset_for_non_padding,
              )
              dense_feat = self.normalizer.normalize(dense_feat)
              logits = self.model(
                  torch.tensor(word_ids),
                  token_bytes,
                  torch.tensor(seq_lens),
                  torch.tensor(dense_feat, dtype=torch.float),
              )
              return self.output_layer(logits)
  
      return ModelWithDenseFeat() if "dense" in tensorizers else Model()
  
imports: from typing import Dict, List, Optional, Union
  import torch
  from pytext.config.component import create_loss
  from pytext.data.tensorizers import ByteTokenTensorizer, FloatListTensorizer, LabelTensorizer, NumericLabelTensorizer, Tensorizer, TokenTensorizer, UidTensorizer, VocabConfig
  from pytext.data.tokenizers import DoNothingTokenizer
  from pytext.exporters.exporter import ModelExporter
  from pytext.loss import BinaryCrossEntropyLoss, BinaryCrossEntropyWithLogitsLoss, MultiLabelSoftMarginLoss
  from pytext.models.decoders.mlp_decoder import DecoderBase, MLPDecoder
  from pytext.models.embeddings import CharacterEmbedding, EmbeddingBase, EmbeddingList, WordEmbedding
  from pytext.models.model import Model
  from pytext.models.module import create_module
  from pytext.models.output_layers import ClassificationOutputLayer, OutputLayerBase, RegressionOutputLayer
  from pytext.models.output_layers.doc_classification_output_layer import BinaryClassificationOutputLayer, MulticlassOutputLayer, MultiLabelOutputLayer
  from pytext.models.representations.bilstm_doc_attention import BiLSTMDocAttention
  from pytext.models.representations.deepcnn import DeepCNNRepresentation
  from pytext.models.representations.docnn import DocNNRepresentation
  from pytext.models.representations.pure_doc_attention import PureDocAttention
  from pytext.models.representations.representation_base import RepresentationBase
  from pytext.torchscript.utils import make_byte_inputs, make_sequence_lengths, truncate_tokens
  from pytext.torchscript.vocab import ScriptVocabulary
  from pytext.utils.label import get_label_weights
  from pytext.utils.usage import log_class_usage
  from pytorch.text.fb.utils.transform_utils import pad_2d
  from torch import jit
label_desc: Use image node_id 4 for calling the ByteTokensDocumentModel obj's underlying member method code with example usage: obj.torchscriptify(tensorizers, traced_model) and returns: unknown, self, self