In the linked code the methods accept arguments such as:
def train_epoch(models, method, criterion, optimizers, dataloaders, epoch, epoch_loss):
    ...

and call these arguments inside the function:
    ...
    target_loss = criterion(scores, labels)

while you are passing optuna_trial as the only argument (besides self) to __call__.
If train or any arguments are not globally defined, the error will be raised.
This tutorial 1 explains function arguments in Python and might be a good starter.