Implement a function that trains a PyTorch model using a custom training loop. The function receives a model, training and validation data loaders, optimizer, loss function, maximum epoch count, gradient clipping threshold, a multiplicative learning-rate decay factor, and early-stopping patience. After each training batch, clip gradients by global norm before the optimizer step. After each epoch, evaluate validation loss, decay the optimizer learning rate by the given factor, and stop early if validation loss does not improve for patience consecutive epochs. Return a dictionary containing the trained model history and the epoch where training stopped.
1 <= max_epochs <= 10^30 < clip_norm <= 10^30 < lr_decay <= 11 <= patience <= max_epochs