import importlib


def get_trainer(cfg, net_G, net_D=None,
                opt_G=None, opt_D=None,
                sch_G=None, sch_D=None,
                train_data_loader=None,
                val_data_loader=None):
    """Return the trainer object.

    Args:
        cfg (Config): Loaded config object.
        net_G (obj): Generator network object.
        net_D (obj): Discriminator network object.
        opt_G (obj): Generator optimizer object.
        opt_D (obj): Discriminator optimizer object.
        sch_G (obj): Generator optimizer scheduler object.
        sch_D (obj): Discriminator optimizer scheduler object.
        train_data_loader (obj): Train data loader.
        val_data_loader (obj): Validation data loader.

    Returns:
        (obj): Trainer object.
    """
    trainer_lib = importlib.import_module(cfg.trainer.type)
    trainer = trainer_lib.Trainer(cfg, net_G, net_D,
                                  opt_G, opt_D,
                                  sch_G, sch_D,
                                  train_data_loader, val_data_loader)
    return trainer