



'''simple docstring'''






import re
from pathlib import Path
from unittest import TestCase

import pytest

@pytest.mark.integration
class 							SCREAMING_SNAKE_CASE(				UpperCAmelCase_     ):







	"""simple docstring"""






	def 	A      (		self     :	Union[str, Any]						,     __snake_case     :	Dict						)     ->						int:




								with open(SCREAMING_SNAKE_CASE_						,     encoding='''utf-8'''						) as input_file:
															UpperCAmelCase					:			Any									=						re.compile(r'''(?!.*\b(?:encoding|rb|w|wb|w+|wb+|ab|ab+)\b)(?<=\s)(open)\((.*)\)'''						)
															UpperCAmelCase					:			Any									=						input_file.read()
															UpperCAmelCase					:			Any									=						regexp.search(SCREAMING_SNAKE_CASE_						)

								return match







	def 	A      (		self     :	Dict						,     __snake_case     :	Dict						)     ->						List[str]:




								with open(SCREAMING_SNAKE_CASE_						,     encoding='''utf-8'''						) as input_file:
															UpperCAmelCase					:			Any									=						re.compile(r'''#[^\r\n]*print\(|\"[^\r\n]*print\(|\"\"\".*?print\(.*?\"\"\"|(print\()'''						,     re.DOTALL						)
															UpperCAmelCase					:			Union[str, Any]									=						input_file.read()
															# use `re.finditer` to handle the case where the ignored groups would be matched first by `re.search`
															UpperCAmelCase					:			List[Any]									=						regexp.finditer(SCREAMING_SNAKE_CASE_						)

								UpperCAmelCase					:			List[Any]									=						[match for match in matches if match is not None and match.group(1						) is not None]
								return matches[0] if matches else None







	def 	A      (		self     :	Dict						)     ->						Tuple:
								UpperCAmelCase					:			Any									=						Path('''./datasets'''						)
								UpperCAmelCase					:			List[Any]									=						list(dataset_paths.absolute().glob('''**/*.py'''						)						)

								for dataset in dataset_files:
															if self._no_encoding_on_file_open(str(SCREAMING_SNAKE_CASE_						)						):
																						raise AssertionError(F"""open(...) must use utf-8 encoding in {dataset}"""						)







	def 	A      (		self     :	List[str]						)     ->						Dict:
								UpperCAmelCase					:			Any									=						Path('''./datasets'''						)
								UpperCAmelCase					:			int									=						list(dataset_paths.absolute().glob('''**/*.py'''						)						)

								for dataset in dataset_files:
															if self._no_print_statements(str(SCREAMING_SNAKE_CASE_						)						):
																						raise AssertionError(F"""print statement found in {dataset}. Use datasets.logger/logging instead."""						)







# 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 		UpperCamelCase						(   lowercase_			,			lowercase_=None			,			lowercase_=None			,			lowercase_=None )		->						Optional[Any]:


  '''simple docstring'''






  lowercase__	: List[Any]     		=   True
  while ask_again:
    lowercase__	: Tuple     		=   input(lowercase_ )
    try:
      if default is not None and len(lowercase_ ) == 0:
        return default
      return convert_value(lowercase_ ) if convert_value is not None else result
    except Exception:
      if error_message is not None:
        print(lowercase_ )

def 		UpperCamelCase						(   lowercase_			,			lowercase_=[]			,			lowercase_=None			,			lowercase_=0 )		->						Union[str, Any]:


  '''simple docstring'''






  lowercase__	: List[Any]     		=   BulletMenu(lowercase_			,			lowercase_ )
  lowercase__	: Any     		=   menu.run(default_choice=lowercase_ )
  return convert_value(lowercase_ ) if convert_value is not None else result

def 		UpperCamelCase						(   lowercase_ )		->						str:


  '''simple docstring'''






  lowercase__	: Union[str, Any]     		=   int(lowercase_ )
  return ComputeEnvironment(["""LOCAL_MACHINE""", """AMAZON_SAGEMAKER"""][value] )

def 		UpperCamelCase						(   lowercase_ )		->						Optional[int]:


  '''simple docstring'''






  lowercase__	: List[str]     		=   int(lowercase_ )
  return DistributedType(["""NO""", """MULTI_CPU""", """MULTI_XPU""", """MULTI_GPU""", """MULTI_NPU""", """TPU"""][value] )

def 		UpperCamelCase						(   lowercase_ )		->						str:


  '''simple docstring'''






  lowercase__	: str     		=   int(lowercase_ )
  return DynamoBackend(DYNAMO_BACKENDS[value] ).value

def 		UpperCamelCase						(   lowercase_ )		->						Union[str, Any]:


  '''simple docstring'''






  lowercase__	: List[Any]     		=   int(lowercase_ )
  return PrecisionType(["""no""", """fp16""", """bf16""", """fp8"""][value] )

def 		UpperCamelCase						(   lowercase_ )		->						Optional[int]:


  '''simple docstring'''






  lowercase__	: List[Any]     		=   int(lowercase_ )
  return SageMakerDistributedType(["""NO""", """DATA_PARALLEL""", """MODEL_PARALLEL"""][value] )

def 		UpperCamelCase						(   lowercase_ )		->						Optional[int]:


  '''simple docstring'''






  return {"yes": True, "no": False}[value.lower()]



class    _snake_case (						argparse.RawDescriptionHelpFormatter				):


 def   lowercase__  (       self       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   lowercase__	: int     		=   super()._format_usage(SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_)
   lowercase__	: Optional[Any]     		=   usage.replace("""<command> [<args>] """       ,	"""""")
   return usage






