code: def test_end_to_end(
      self,
      train_parameters: bool,
      last_layer_only: bool,
      gradient_checkpointing: bool,
  ):
      tokenizer = PretrainedTransformerTokenizer(
          model_name="bert-base-uncased"
      )
      token_indexer = PretrainedTransformerIndexer(
          model_name="bert-base-uncased"
      )
  
      sentence1 = "A, AllenNLP sentence."
      tokens1 = tokenizer.tokenize(sentence1)
      expected_tokens1 = [
          "[CLS]",
          "a",
          ",",
          "allen",
          "##nl",
          "##p",
          "sentence",
          ".",
          "[SEP]",
      ]
      assert [t.text for t in tokens1] == expected_tokens1
  
      sentence2 = "AllenNLP is great"
      tokens2 = tokenizer.tokenize(sentence2)
      expected_tokens2 = [
          "[CLS]",
          "allen",
          "##nl",
          "##p",
          "is",
          "great",
          "[SEP]",
      ]
      assert [t.text for t in tokens2] == expected_tokens2
  
      vocab = Vocabulary()
  
      params = Params(
          {
              "token_embedders": {
                  "bert": {
                      "type": "pretrained_transformer",
                      "model_name": "bert-base-uncased",
                      "train_parameters": train_parameters,
                      "last_layer_only": last_layer_only,
                      "gradient_checkpointing": gradient_checkpointing,
                  }
              }
          }
      )
      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"]
      max_length = max(len(tokens1), len(tokens2))
  
      assert tokens["bert"]["token_ids"].shape == (2, max_length)
  
      assert tokens["bert"]["mask"].tolist() == [
          [True, True, True, True, True, True, True, True, True],
          [True, True, True, True, True, True, True, False, False],
      ]
  
      # Attention mask
      bert_vectors = token_embedder(tokens)
      assert bert_vectors.size() == (2, 9, 768)
      assert bert_vectors.requires_grad == (
          train_parameters or not last_layer_only
      )
  
imports: import math
  import pytest
  import torch
  from allennlp.common import Params, cached_transformers
  from allennlp.common.testing import AllenNlpTestCase, requires_gpu
  from allennlp.data import 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 PretrainedTransformerIndexer
  from allennlp.data.tokenizers import PretrainedTransformerTokenizer
  from allennlp.modules.text_field_embedders import BasicTextFieldEmbedder
  from allennlp.modules.token_embedders import PretrainedTransformerEmbedder
label_desc: Use image node_id 3 for calling the TestPretrainedTransformerEmbedder obj's underlying member method code with example usage: obj.test_end_to_end(train_parameters, last_layer_only, gradient_checkpointing) without return types