def train_model(self, train_data, output_dir=None, show_running_loss=True, args=None, eval_data=None, verbose=True, **kwargs):
    "\n        Trains the model using 'train_data'\n\n        Args:\n            train_data: Pandas DataFrame containing the 2 columns - `input_text`, `target_text`.\n                        - `input_text`: The input text sequence.\n                        - `target_text`: The target text sequence\n            output_dir: The directory where model files will be saved. If not given, self.args.output_dir will be used.\n            show_running_loss (optional): Set to False to prevent running loss from being printed to console. Defaults to True.\n            args (optional): Optional changes to the args dict of the model. Any changes made will persist for the model.\n            eval_data (optional): A DataFrame against which evaluation will be performed when evaluate_during_training is enabled. Is required if evaluate_during_training is enabled.\n            **kwargs: Additional metrics that should be used. Pass in the metrics as keyword arguments (name of metric: function to use).\n                        A metric function should take in two parameters. The first parameter will be the true labels, and the second parameter will be the predictions. Both inputs\n                        will be lists of strings. Note that this will slow down training significantly as the predicted sequences need to be generated.\n\n        Returns:\n            None\n        "
    if args:
        self.args.update_from_dict(args)
    if (self.args.evaluate_during_training and (eval_data is None)):
        raise ValueError('evaluate_during_training is enabled but eval_data is not specified. Pass eval_data to model.train_model() if using evaluate_during_training.')
    if (not output_dir):
        output_dir = self.args.output_dir
    if (os.path.exists(output_dir) and os.listdir(output_dir) and (not self.args.overwrite_output_dir)):
        raise ValueError('Output directory ({}) already exists and is not empty. Set args.overwrite_output_dir = True to overcome.'.format(output_dir))
    self._move_model_to_device()
    train_dataset = self.load_and_cache_examples(train_data, verbose=verbose)
    os.makedirs(output_dir, exist_ok=True)
    (global_step, tr_loss) = self.train(train_dataset, output_dir, show_running_loss=show_running_loss, eval_data=eval_data, verbose=verbose, **kwargs)
    self._save_model(self.args.output_dir, model=self.model)
    if verbose:
        logger.info(' Training of {} model complete. Saved to {}.'.format(self.args.model_name, output_dir))
Trains the model using 'train_data'

Args:
    train_data: Pandas DataFrame containing the 2 columns - `input_text`, `target_text`.
                - `input_text`: The input text sequence.
                - `target_text`: The target text sequence
    output_dir: The directory where model files will be saved. If not given, self.args.output_dir will be used.
    show_running_loss (optional): Set to False to prevent running loss from being printed to console. Defaults to True.
    args (optional): Optional changes to the args dict of the model. Any changes made will persist for the model.
    eval_data (optional): A DataFrame against which evaluation will be performed when evaluate_during_training is enabled. Is required if evaluate_during_training is enabled.
    **kwargs: Additional metrics that should be used. Pass in the metrics as keyword arguments (name of metric: function to use).
                A metric function should take in two parameters. The first parameter will be the true labels, and the second parameter will be the predictions. Both inputs
                will be lists of strings. Note that this will slow down training significantly as the predicted sequences need to be generated.

Returns:
    None
def train_model(self, train_data, output_dir=None, show_running_loss=True, args=None, eval_data=None, verbose=True, **kwargs):
    "\n        Trains the model using 'train_data'\n\n        Args:\n            train_data: Pandas DataFrame containing the 2 columns - `input_text`, `target_text`.\n                        - `input_text`: The input text sequence.\n                        - `target_text`: The target text sequence\n            output_dir: The directory where model files will be saved. If not given, self.args.output_dir will be used.\n            show_running_loss (optional): Set to False to prevent running loss from being printed to console. Defaults to True.\n            args (optional): Optional changes to the args dict of the model. Any changes made will persist for the model.\n            eval_data (optional): A DataFrame against which evaluation will be performed when evaluate_during_training is enabled. Is required if evaluate_during_training is enabled.\n            **kwargs: Additional metrics that should be used. Pass in the metrics as keyword arguments (name of metric: function to use).\n                        A metric function should take in two parameters. The first parameter will be the true labels, and the second parameter will be the predictions. Both inputs\n                        will be lists of strings. Note that this will slow down training significantly as the predicted sequences need to be generated.\n\n        Returns:\n            None\n        "
    if args:
        self.args.update_from_dict(args)
    if (self.args.evaluate_during_training and (eval_data is None)):
        raise ValueError('evaluate_during_training is enabled but eval_data is not specified. Pass eval_data to model.train_model() if using evaluate_during_training.')
    if (not output_dir):
        output_dir = self.args.output_dir
    if (os.path.exists(output_dir) and os.listdir(output_dir) and (not self.args.overwrite_output_dir)):
        raise ValueError('Output directory ({}) already exists and is not empty. Set args.overwrite_output_dir = True to overcome.'.format(output_dir))
    self._move_model_to_device()
    train_dataset = self.load_and_cache_examples(train_data, verbose=verbose)
    os.makedirs(output_dir, exist_ok=True)
    (global_step, tr_loss) = self.train(train_dataset, output_dir, show_running_loss=show_running_loss, eval_data=eval_data, verbose=verbose, **kwargs)
    self._save_model(self.args.output_dir, model=self.model)
    if verbose:
        logger.info(' Training of {} model complete. Saved to {}.'.format(self.args.model_name, output_dir))