code: def test_throws_error_on_incorrect_sub_token_mode(
      self, sub_token_mode: str
  ):
      token_indexer = PretrainedTransformerMismatchedIndexer(
          "bert-base-uncased"
      )
  
      sentence1 = ["A", ",", "AllenNLP", "sentence", "."]
      sentence2 = ["AllenNLP", "is", "open", "source", "NLP", "library"]
  
      tokens1 = [Token(word) for word in sentence1]
      tokens2 = [Token(word) for word in sentence2]
  
      vocab = Vocabulary()
  
      params = Params(
          {
              "token_embedders": {
                  "bert": {
                      "type": "pretrained_transformer_mismatched",
                      "model_name": "bert-base-uncased",
                      "sub_token_mode": sub_token_mode,
                  }
              }
          }
      )
      token_embedder = BasicTextFieldEmbedder.from_params(
          vocab=vocab, params=params
      )
  
      instance1 = Instance(
          {"tokens": TextField(tokens1, {"bert": token_indexer})}
      )
      instance2 = Instance(
          {"tokens": TextField(tokens2, {"bert": token_indexer})}
      )
  
      batch = Batch([instance1, instance2])
      batch.index_instances(vocab)
  
      padding_lengths = batch.get_padding_lengths()
      tensor_dict = batch.as_tensor_dict(padding_lengths)
      tokens = tensor_dict["tokens"]
  
      with pytest.raises(ConfigurationError):
          token_embedder(tokens)
  
imports: import pytest
  import torch
  from allennlp.common import Params, cached_transformers
  from allennlp.common.checks import ConfigurationError
  from allennlp.data import Token, Vocabulary
  from allennlp.data.batch import Batch
  from allennlp.data.fields import TextField
  from allennlp.data.instance import Instance
  from allennlp.data.token_indexers import PretrainedTransformerMismatchedIndexer
  from allennlp.modules.text_field_embedders import BasicTextFieldEmbedder
  from allennlp.modules.token_embedders import PretrainedTransformerMismatchedEmbedder
  from allennlp.common.testing import AllenNlpTestCase
label_desc: Use image node_id 7 for calling the TestPretrainedTransformerMismatchedEmbedder obj's underlying member method code with example usage: obj.test_throws_error_on_incorrect_sub_token_mode(sub_token_mode) without return types