Custom constructed and trained `tokenizers.Tokenizer` for Albert error.
Author: xrkk
Pull request: no

I created and traind a custom tokenizer for BERT following example in this page: https://huggingface.co/docs/tokenizers/python/latest/pipeline.html

```py
from tokenizers import Tokenizer
from tokenizers.models import WordPiece
bert_tokenizer = Tokenizer(WordPiece(unk_token="[UNK]"))

from tokenizers import normalizers
from tokenizers.normalizers import Lowercase, NFD, StripAccents
bert_tokenizer.normalizer = normalizers.Sequence([NFD(), Lowercase(), StripAccents()])

from tokenizers.pre_tokenizers import Whitespace
bert_tokenizer.pre_tokenizer = Whitespace()

from tokenizers.processors import TemplateProcessing
bert_tokenizer.post_processor = TemplateProcessing(
    single="[CLS] $A [SEP]",
    pair="[CLS] $A [SEP] $B:1 [SEP]:1",
    special_tokens=[
        ("[CLS]", 1),
        ("[SEP]", 2),
    ],
)

from tokenizers.trainers import WordPieceTrainer
trainer = WordPieceTrainer(
    vocab_size=30522, special_tokens=["[UNK]", "[CLS]", "[SEP]", "[PAD]", "[MASK]"]
)
# files = [f"data/wikitext-103-raw/wiki.{split}.raw" for split in ["test", "train", "valid"]]
# bert_tokenizer.train(files, trainer)
# bert_tokenizer.save("data/bert-wiki.json")
bert_tokenizer.train(f_path_list, trainer)           # my own file list
bert_tokenizer.save(tkn_path, pretty=True)     # some .json on disk
```

Then, I loaded it from disk with this:
```py
tokenizer: Tokenizer = Tokenizer.from_file(tkn_path)
```

But, when I use it to tokenize some text, error appears:
```py
def tokenize_function(examples: Batch):
    # Error: 'tokenizers.Tokenizer' object is not callable
    return tokenizer(examples['text'], return_special_tokens_mask=True)
with training_args.main_process_first(desc="dataset map tokenization"):
    tokenized_datasets = raw_datasets.map(
        tokenize_function,
        batched=True,
        num_proc=8,
        remove_columns=raw_datasets["train"].column_names,
        desc="...",
    )
````

Then, I changed `tokenizer(...)` with `tokenizer.encode(....)`, another error appears:
```py
def tokenize_function(examples: Batch):
    # Error: Provided `function` which is applied to all elements of table returns a variable of type <class 'list'>
    return tokenizer.encode(examples['text'])
with training_args.main_process_first(desc="dataset map tokenization"):
    tokenized_datasets = raw_datasets.map(
        tokenize_function,
        batched=True,
        num_proc=8,
        remove_columns=raw_datasets["train"].column_names,
        desc="...",
    )
```

Then, I changed the way to load tokenizer to below:
```py
tokenizer = PreTrainedTokenizerFast(tokenizer_file=tkn_path)
```

But when tokenized stuff passed into model, this error appears:
```py
ValueError: This tokenizer does not have a mask token which is necessary for masked language modeling. You should pass `mlm=False` to train on causal language modeling instead.
```

How can I really train albert with my own tokenizer?


Comments:
Solved.

Tokenizer created、trained、saved in `tokenizers` library, can be loaded in `transformers` library in this way:
```
tokenizer = PreTrainedTokenizerFast(tokenizer_object=Tokenizer.from_file(tkn_path))
```

Since I'm using tokenizer for mlm tasks, I shall use it in this way:
```
tokenizer = BertTokenizerFast(tokenizer_object=Tokenizer.from_file(tkn_path))
```

Check this out: https://colab.research.google.com/github/huggingface/notebooks/blob/master/examples/tokenizer_training.ipynb