def worker(local_rank, gpu_ranks, args):
    """
    Args:
        local_rank: The id of GPU for single GPU mode;
                    The id of process (and GPU) for multiprocessing distributed mode.
        gpu_ranks: List of ranks of each process.
    """
    set_seed(args.seed)

    # Get logger
    args.logger = init_logger(args)

    # Env initialize.
    args.local_rank = local_rank
    init_env(args)
    global_rank = args.global_rank

    # Build model.
    model = init_model(args)

    # Build optimizer.
    custom_optimizer, custom_scheduler = init_optimizer(args, model)

    if local_rank is not None:
        model.cuda(local_rank)
    optimizer = custom_optimizer
    scheduler = custom_scheduler

    if args.dist_train:
        model = DistributedDataParallel(model, device_ids=[local_rank], find_unused_parameters=True)
        args.logger.info("Worker %d is training ... " % global_rank)
    else:
        args.logger.info("Worker is training ...")

    if args.dist_train:
        train_loader = str2dataloader[args.data_processor](args, args.dataset_path, args.batch_size, global_rank, args.world_size, local_rank, True)
    else:
        train_loader = str2dataloader[args.data_processor](args, args.dataset_path, args.batch_size, 0, 1, local_rank, True)


    trainer = str2trainer[args.data_processor](args)
    trainer.train(args, local_rank, global_rank, train_loader, model, optimizer, scheduler)

    Args:
        local_rank: The id of GPU for single GPU mode;
                    The id of process (and GPU) for multiprocessing distributed mode.
        gpu_ranks: List of ranks of each process.
    
uer/trainer.py