def accel_image(config, args):
    """
    Selects and the appropriate image based on config, arguments, environment.
    """
    # Try to resolve using args/environment/config
    image = resolve_image_from_args_and_env(config, args)
    if image:
        return image

    conman = config['engine']
    images = config['images']
    set_gpu_type_env_vars()
    if gpu_type_env_vars := get_gpu_type_env_vars():
        gpu_type, _ = next(iter(gpu_type_env_vars.items()))
    else:
        gpu_type = None

    # Get image based on detected GPU type
    image = images.get(gpu_type, config["image"])

    # Special handling for CUDA images based on version - only if the image is the default CUDA image
    cuda_image = images.get("CUDA_VISIBLE_DEVICES")
    if image == cuda_image:
        image = select_cuda_image(config)

    if not args:
        return tagged_image(image)

    if args.runtime == "vllm":
        return "registry.redhat.io/rhelai1/ramalama-vllm"

    if hasattr(args, "rag") and args.rag:
        image += "-rag"

    vers = minor_release()
    if args.container and attempt_to_use_versioned(conman, image, vers, args.quiet):
        return f"{image}:{vers}"

    return f"{image}:latest"

    Selects and the appropriate image based on config, arguments, environment.
    
ramalama/common.py