Without seeing how you use train_resnet, I’m assuming your issue is in how you’re calling loss. If loss is a regular Keras loss function, it just expects y_true and y_pred, so in grad you’d do something like:
def grad(model, inputs, targets, loss):
   with tf.GradientTape() as tape:
       preds = model(inputs, training=True)
       loss_value = loss(inputs, targets)
       return (loss_value, tape.gradient(loss_value, model.trainable_variables))