import torch


def _define_model(model, model_path, gpu):
    """
    Define model given some parameters.
    :param model: Model enumeration.
    :param model_path: Model file path.
    :param gpu: If GPU is available or not.
    :return: Model instance.
    """
    net = model.value()
    if gpu:
        net.load_state_dict(torch.load(model_path))
        if torch.cuda.is_available():
            net.cuda()
    else:
        net.load_state_dict(torch.load(model_path, map_location='cpu'))
    net.eval()
    return net