code: def tokenize(self, tokenizer):
      # masked_tokens will be regular tokens except with tokenizer.mask_token for masked spans
      # label_tokens will be tokenizer.pad_token except with the regular tokens for masked spans
      masked_tokens = []
      label_tokens = []
      curr = 0
      for start, end in self.masked_spans:
          # Handle text before next mask
          tokenized_text = tokenizer.tokenize(self.text[curr:start])
          masked_tokens += tokenized_text
          label_tokens += [tokenizer.pad_token] * len(tokenized_text)
  
          # Handle mask
          tokenized_masked_text = tokenizer.tokenize(
              self.text[start:end]
          )
          masked_tokens += [tokenizer.mask_token] * len(
              tokenized_masked_text
          )
          label_tokens += tokenized_masked_text
          curr = end
      if curr < len(self.text):
          tokenized_text = tokenizer.tokenize(self.text[curr:])
          masked_tokens += tokenized_text
          label_tokens += [tokenizer.pad_token] * len(tokenized_text)
  
      return TokenizedExample(
          guid=self.guid,
          masked_tokens=masked_tokens,
          label_tokens=label_tokens,
      )
  
file_path: jiant/jiant/tasks/lib/templates/mlm_premasked.py
imports: import numpy
  import torch
  from dataclasses import dataclass
  from typing import List
  from jiant.tasks.lib.templates import mlm
  from jiant.tasks.core import BaseExample, BaseTokenizedExample, BaseDataRow, BatchMixin
  from jiant.tasks.utils import ExclusiveSpan, truncate_sequences
  from jiant.tasks.lib.templates.shared import construct_single_input_tokens_and_segment_ids, create_input_set_from_tokens_and_segments, pad_single_with_feat_spec
label_desc: Use image node_id 1 for calling the Example obj's underlying member method code with example usage: obj.tokenize(tokenizer) and returns: TokenizedExample