trainer = Trainer(
    model,
    args,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset,
    callbacks=[MyCallback],  # We can either pass the callback class this way or an instance of it (MyCallback())
)

Another way to register a callback is to call trainer.add_callback() as follows:
thon
trainer = Trainer()
trainer.add_callback(MyCallback)
Alternatively, we can pass an instance of the callback class
trainer.add_callback(MyCallback())