code: def _mock_tensoriser(self):
      class MockTensoriser(TensorizerScriptImpl):
          def __init__(self):
              super().__init__()
  
          def tokenize(
              self,
              row: Optional[List[str]],
              row_pre_tokenized: Optional[List[List[str]]],
          ) -> List[List[Tuple[str, int, int]]]:
              tokens: List[List[Tuple[str, int, int]]] = []
  
              # handle row_pre_tokenized
              # this mock implementation will return early and use `row_pre_tokenized` if it's available;
              # otherwise, it defaults back to `row`.
              if row_pre_tokenized is not None:
                  for text in row_pre_tokenized:
                      res: List[Tuple[str, int, int]] = []
                      prev: int = 0
                      for i, w in enumerate(text):
                          res.append(
                              (w, i + prev, i + prev + len(w) - 1)
                          )
                          prev += len(w)
                      tokens.append(res)
                  return tokens
  
              # handle row if row_pre_tokenized is not defined
              if row is not None:
                  for text in row:
                      res: List[Tuple[str, int, int]] = []
                      prev: int = 0
                      for i, w in enumerate(text.split()):
                          res.append(
                              (w, i + prev, i + prev + len(w) - 1)
                          )
                          prev += len(w)
                      tokens.append(res)
  
              return tokens
  
          def numberize(
              self, inp: List[List[Tuple[str, int, int]]]
          ) -> List[int]:
              res: List[int] = []
              for row in inp:
                  res.extend([int(x) for x, _, _ in row])
              return res
  
          def tensorize(self, n: List[int]) -> torch.Tensor:
              return torch.tensor(n, dtype=torch.int)
  
          def forward(self, inputs: ScriptBatchInput) -> torch.Tensor:
              res: List[int] = []
              for idx in range(self.batch_size(inputs)):
                  res.extend(
                      self.numberize(
                          self.tokenize(
                              self.get_texts_by_index(
                                  inputs.texts, idx
                              ),
                              None,
                          )
                      )
                  )
              return self.tensorize(res)
  
      return MockTensoriser()
  
imports: import random
  import string
  import unittest
  from typing import List, Optional, Tuple
  import torch
  from pytext.data.tensorizers import TensorizerScriptImpl
  from pytext.torchscript.module import PyTextEmbeddingModule, ScriptPyTextEmbeddingModule
  from pytext.torchscript.tensorizer.tensorizer import ScriptTensorizer, VocabLookup
  from pytext.torchscript.utils import pad_2d_mask, ScriptBatchInput
  from pytext.torchscript.vocab import ScriptVocabulary
  from pytorch.text.fb.utils.transform_utils import pad_2d
label_desc: Use image node_id 2 for calling the ScriptPyTextEmbeddingModuleTest obj's underlying member method code with example usage: obj._mock_tensoriser() and returns: MockTensoriser, tokens, res, torch, self, tokens