# Pt Train RNN Model Trains an RNN model using a given dataset, loss function, optimizer, and number of epochs with learning rate decay. Args: model (PTMODEL): The PyTorch model to be trained. linear_head (bool): The RNN model has a Linear head. train_loader (torch.utils.data.DataLoader): DataLoader containing the training dataset. optimizer (PTOPTIMIZER): Optimizer used for training. loss (PTLOSS): The loss class. epochs (int): Number of training epochs. use_gpu (bool): Whether to use GPU for training. early_stopping (bool): Whether to turn on early stopping early_stopping_rounds (int): Specifies the number of rounds to monitor the evaluation loss when early_stopping is enabled and validation data is specified. If the loss does not decrease compared to the current best loss within this period, training will be stopped. output_best_val_model (bool): Whether to outputs the model with the best val loss or the model from the last epoch. classification_metrics (bool): If True and if val_loader is set, print out classification metrics. This is only valid for classification model training. use_valid_token_mean (bool): Computes the mean of the RNN output for non-zero inputs and feeds to the linear layer. val_loader (PTDATALOADER): DataLoader for validation dataset (optional). scheduler (PTLRSCHEDULER): Learning rate scheduler. h_0 (TENSOR): Optional initial hidden state. For unidirectional models, the shape is [num_layers, batch_size, hidden_size]. For bidirectional models, it is [2 * num_layers, batch_size, hidden_size]. If not provided, a zero tensor is used. ## Input | Name | Data type | |---|---| | model | Ptmodel | | linear_head | Boolean | | train_loader | Ptdataloader | | optimizer | Ptoptimizer | | loss_function | Ptloss | | epochs | Int | | use_gpu | Boolean | | early_stopping | Boolean | | early_stopping_rounds | Int | | output_best_val_model | Boolean | | classification_metrics | Boolean | | use_valid_token_mean | Boolean | | scheduler | Ptlrscheduler | | val_loader | Ptdataloader | | h_0 | Tensor | ## Output | Data type | |---| | Ptmodel | | Tensor | | Tensor |