Pushing a tensorflow model to hugging face hub

I have trained a hybrid model using a TFXLNetModel layer followed by a Tensorflow LSTM layer. I was confused how this model can be pushed to the hub for serverless inference, as I don’t find any example on the docs on how to do this. Please could I have some help on this?

The code is below for reference

def xlnet_tweets_model():
    xlnet_encoder = TFXLNetModel.from_pretrained("xlnet-base-cased")
    input_word_ids = tf.keras.Input(shape=(max_length,), dtype=tf.int32, name="input_ids")
    last_hidden_states = xlnet_encoder.transformer(input_word_ids)[0]    
    x = tf.keras.layers.LSTM(100, dropout=0.3, recurrent_dropout=0.3)(last_hidden_states)
    output = tf.keras.layers.Dense(3, activation='softmax')(x)
    model = tf.keras.Model(inputs=input_word_ids, outputs=output)
    
    return model

model = xlnet_tweets_model()
adam_optimizer = tf.keras.optimizers.Adam(learning_rate=1e-5)
model.compile(loss='sparse_categorical_crossentropy',optimizer=adam_optimizer,metrics=['accuracy'])

history = model.fit(
    train_dataset,
    batch_size=batch_size,
    epochs=5,
    validation_data=val_dataset,
    verbose=2,

I’ve tried using the following code to push the model that has been trained to the HF hub but it give the following error

model.push_to_hub("my_model")

The error is this:

AttributeError
----> 1 model.push_to_hub("my_model")

AttributeError: 'Functional' object has no attribute 'push_to_hub'