code: def test_token_idx_roberta(self):
      sentence = "A, naïve <mask> AllenNLP sentence."
      expected_tokens = [
          "<s>",
          "A",
          ",",
          "ĠnaÃ¯ve",  # RoBERTa mangles this. Or maybe it "encodes"?
          "<mask>",
          "ĠAllen",
          "N",
          "LP",
          "Ġsentence",
          ".",
          "</s>",
      ]
      expected_idxs = [None, 0, 1, 3, 9, 16, 21, 22, 25, 33, None]
      tokenizer = PretrainedTransformerTokenizer("roberta-base")
      tokenized = tokenizer.tokenize(sentence)
      tokens = [t.text for t in tokenized]
      assert tokens == expected_tokens
      idxs = [t.idx for t in tokenized]
      assert idxs == expected_idxs
  
imports: from typing import Iterable, List
  import pytest
  from allennlp.common import Params
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data import Token
  from allennlp.data.tokenizers import PretrainedTransformerTokenizer
label_desc: Use image node_id 9 for calling the TestPretrainedTransformerTokenizer obj's underlying member method code with example usage: obj.test_token_idx_roberta() without return types