'TypeError : 'NoneType' object is not callable (XLNet Classifer)

I am trying to train my model using Tokenizer,Keras and TensorFlow. Code where I'm getting the error.

from transformers import TFXLNetModel, XLNetTokenizer
xlnet_model = 'xlnet-large-cased'
xlnet_tokenizer = XLNetTokenizer.from_pretrained(xlnet_model) 

Error:

enter image description here



Solution 1:[1]

If you run the code you will first get this error:

ImportError: 
XLNetTokenizer requires the SentencePiece library but it was not found in your environment. Checkout the instructions on the
installation page of its repo: https://github.com/google/sentencepiece#installation and follow the ones
that match your environment

After running !pip install sentencepiece and restarting the cell the TypeError happens.

To fix this you need to restart your runtime. Click "Runtime -> Restart Runtime", then run your cells again.

I found this solution on the transformers repo in this issue report.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lomtrur