



# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from ...utils.dataclasses import (
    ComputeEnvironment,
    DistributedType,
    DynamoBackend,
    PrecisionType,
    SageMakerDistributedType,
)
from ..menu import BulletMenu


_lowerCamelCase    :		Optional[int]		      =    [
    """EAGER""",
    """AOT_EAGER""",
    """INDUCTOR""",
    """NVFUSER""",
    """AOT_NVFUSER""",
    """AOT_CUDAGRAPHS""",
    """OFI""",
    """FX2TRT""",
    """ONNXRT""",
    """IPEX""",
]

def        __a			(   __lowerCAmelCase      ,	__lowerCAmelCase=None      ,	__lowerCAmelCase=None      ,	__lowerCAmelCase=None   )     ->     Tuple:
					SCREAMING_SNAKE_CASE							:     Optional[Any]						=				True
					while ask_again:
										SCREAMING_SNAKE_CASE							:     Optional[int]						=				input(__lowerCAmelCase   )
										try:
															if default is not None and len(__lowerCAmelCase   ) == 0:
																				return default
															return convert_value(__lowerCAmelCase   ) if convert_value is not None else result
										except Exception:
															if error_message is not None:
																				print(__lowerCAmelCase   )

def        __a			(   __lowerCAmelCase      ,	__lowerCAmelCase=[]      ,	__lowerCAmelCase=None      ,	__lowerCAmelCase=0   )     ->     List[str]:
					SCREAMING_SNAKE_CASE							:     Dict						=				BulletMenu(__lowerCAmelCase      ,	__lowerCAmelCase   )
					SCREAMING_SNAKE_CASE							:     Tuple						=				menu.run(default_choice=__lowerCAmelCase   )
					return convert_value(__lowerCAmelCase   ) if convert_value is not None else result

def        __a			(   __lowerCAmelCase   )     ->     Dict:
					SCREAMING_SNAKE_CASE							:     Any						=				int(__lowerCAmelCase   )
					return ComputeEnvironment(['LOCAL_MACHINE', 'AMAZON_SAGEMAKER'][value]   )

def        __a			(   __lowerCAmelCase   )     ->     List[str]:
					SCREAMING_SNAKE_CASE							:     Optional[int]						=				int(__lowerCAmelCase   )
					return DistributedType(['NO', 'MULTI_CPU', 'MULTI_XPU', 'MULTI_GPU', 'MULTI_NPU', 'TPU'][value]   )

def        __a			(   __lowerCAmelCase   )     ->     Optional[int]:
					SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				int(__lowerCAmelCase   )
					return DynamoBackend(DYNAMO_BACKENDS[value]   ).value

def        __a			(   __lowerCAmelCase   )     ->     Any:
					SCREAMING_SNAKE_CASE							:     Dict						=				int(__lowerCAmelCase   )
					return PrecisionType(['no', 'fp16', 'bf16', 'fp8'][value]   )

def        __a			(   __lowerCAmelCase   )     ->     Dict:
					SCREAMING_SNAKE_CASE							:     int						=				int(__lowerCAmelCase   )
					return SageMakerDistributedType(['NO', 'DATA_PARALLEL', 'MODEL_PARALLEL'][value]   )

def        __a			(   __lowerCAmelCase   )     ->     Optional[int]:
					return {"yes": True, "no": False}[value.lower()]



class 						lowercase    (							argparse.RawDescriptionHelpFormatter):
						'''simple docstring'''


						def       lowerCamelCase_				(  self    :				str       ,	snake_case    :				Union[str, Any]       ,	snake_case    :				int       ,	snake_case    :				List[Any]       ,	snake_case    :				int	):



											'''simple docstring'''


											SCREAMING_SNAKE_CASE							:     Optional[Any]						=				super()._format_usage(snake_case       ,	snake_case       ,	snake_case       ,	snake_case	)
											SCREAMING_SNAKE_CASE							:     Union[str, Any]						=				usage.replace('<command> [<args>] '       ,	''	)
											return usage




import numpy as np
from sklearn.datasets import fetch_california_housing
from sklearn.metrics import mean_absolute_error, mean_squared_error
from sklearn.model_selection import train_test_split
from xgboost import XGBRegressor

def        __a			(   __lowerCAmelCase   )     ->     tuple:
					return (data["data"], data["target"])

def        __a			(   __lowerCAmelCase      ,	__lowerCAmelCase      ,	__lowerCAmelCase   )     ->     np.ndarray:
					SCREAMING_SNAKE_CASE							:     int						=				XGBRegressor(verbosity=0      ,	random_state=42   )
					xgb.fit(__lowerCAmelCase      ,	__lowerCAmelCase   )
					# Predict target for test data
					SCREAMING_SNAKE_CASE							:     List[Any]						=				xgb.predict(__lowerCAmelCase   )
					SCREAMING_SNAKE_CASE							:     str						=				predictions.reshape(len(__lowerCAmelCase   )      ,	1   )
					return predictions

def        __a			(   )     ->     None:
					SCREAMING_SNAKE_CASE							:     Dict						=				fetch_california_housing()
					SCREAMING_SNAKE_CASE					,  SCREAMING_SNAKE_CASE							:     Any						=				data_handling(__lowerCAmelCase   )
					SCREAMING_SNAKE_CASE					,  SCREAMING_SNAKE_CASE					,  SCREAMING_SNAKE_CASE					,  SCREAMING_SNAKE_CASE							:     str						=				train_test_split(
					    __lowerCAmelCase      ,	__lowerCAmelCase      ,	test_size=0.25      ,	random_state=1   )
					SCREAMING_SNAKE_CASE							:     int						=				xgboost(__lowerCAmelCase      ,	__lowerCAmelCase      ,	__lowerCAmelCase   )
					# Error printing
					print(F'''Mean Absolute Error : {mean_absolute_error(__lowerCAmelCase      ,	__lowerCAmelCase   )}'''   )
					print(F'''Mean Square Error  : {mean_squared_error(__lowerCAmelCase      ,	__lowerCAmelCase   )}'''   )


if __name__ == "__main__":
			import doctest

			doctest.testmod(verbose=True)
			main()