def METHOD_NAME(args):
    if hasattr(args, "device_type"):
        if args.device_type == "cpu":
            device_type = "cpu"
        elif args.device_type == "gpu":
            if ml_engine_adapter.is_device_available(args, args.device_type):
                device_type = "gpu"
            else:
                print("ML engine install was not built with GPU enabled")
                device_type = "cpu"
        elif args.device_type == "mps":
            # Macbook M1: https://pytorch.org/docs/master/notes/mps.html
            if not ml_engine_adapter.is_device_available(args, args.device_type):
                device_type = "cpu"
            else:
                device_type = "mps"
        else:
            raise Exception("do not support device type = {}".format(args.device_type))
    else:
        if args.using_gpu:
            if ml_engine_adapter.is_device_available(args, "gpu"):
                device_type = "gpu"
            else:
                print("ML engine install was not built with GPU enabled")
                device_type = "cpu"
        else:
            device_type = "cpu"
    return device_type