def create_training_model(config: model.ModelConfig,
                          context: List[mx.Context],
                          output_dir: str,
                          train_iter: data_io.BaseParallelSampleIter,
                          args: argparse.Namespace) -> training.TrainingModel:
    """
    Create a training model and load the parameters from disk if needed.

    :param config: The configuration for the model.
    :param context: The context(s) to run on.
    :param output_dir: Output folder.
    :param train_iter: The training data iterator.
    :param args: Arguments as returned by argparse.
    :return: The training model.
    """
    training_model = training.TrainingModel(config=config,
                                            context=context,
                                            output_dir=output_dir,
                                            provide_data=train_iter.provide_data,
                                            provide_label=train_iter.provide_label,
                                            default_bucket_key=train_iter.default_bucket_key,
                                            bucketing=not args.no_bucketing,
                                            gradient_compression_params=gradient_compression_params(args),
                                            gradient_accumulation=args.update_interval > 1,
                                            fixed_param_names=args.fixed_param_names,
                                            fixed_param_strategy=args.fixed_param_strategy)

    return training_model
Create a training model and load the parameters from disk if needed.

    :param config: The configuration for the model.
    :param context: The context(s) to run on.
    :param output_dir: Output folder.
    :param train_iter: The training data iterator.
    :param args: Arguments as returned by argparse.
    :return: The training model.