Thank you for your reply. I have another question. I have implemented the model, but now I want to implement TapasTokenizer, which prepares the data for the model. The API would look like this:
from transformers import TapasTokenizer

data = {'Actors': ["Brad Pitt", "Leonardo Di Caprio"], 'Number of movies': ["87", "53"]}
table = pd.DataFrame.from_dict(data)
queries = ["What is the name of the first actor?", "How many movies has he played in?"]
answer_coordinates = [(0, 0), (0, 1)]
answer_text = ["Brad Pitt", "87"]

tokenizer = TapasTokenizer.from_pretrained("tapas-base-finetuned-sqa")
inputs = tokenizer(table, queries, answer_coordinates, answer_text)

The “inputs” dictionary should contain the following:
{'input_ids': [[  101,  2054,  2003,  1996,  2171,  1997,  1996,  2034,  3364,  1029, 102,  3364,  2193,  1997,  5691,  8226, 15091,  5187, 14720,  4487, 6178,  9488,  6584], 
                [101,  2129,  2116,  5691,  2038, 14720,  4487,  6178,  9488,  2209, 1999,  1029,   102,  3364,  2193,  1997,  5691,  8226, 15091,  5187, 14720,  4487,  6178,  9488,  6584],
'token_type_ids': [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                            [0, 0, 0, 0, 0, 0, 0, 0, 0]],
'attention_mask': [[1, 1, 1, 1, 1, 1, 1, 1, 1],
                             [1, 1, 1, 1, 1, 0, 0, 0, 0]],
'label_ids':  [[...],[...]],
'answer': [[nan], ["87"]],
'aggregation_function_id': [[0],[0]],
'numeric_values': [...],
'numeric_values_scale': [...]
}

TapasTokenizer uses the same vocabulary as BERT, but it encodes tables and associated queries. The inputs ids are [CLS] query [SEP] flattened table, and it creates additional token type ids to encode tabular structure. In case one also wants to compute the loss, it creates answer, aggregation function id, numeric values and numeric values scale lists/tensors. What is the best way to implement this? Which function of BertTokenizer should I overwrite to use TapasTokenizer as shown above? Or should I let TapasTokenizer just inherit from PretrainedTokenizer and define the encode function?