





# 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


UpperCAmelCase_					:   Union[str, Any] 							=						[
    """EAGER""",
    """AOT_EAGER""",
    """INDUCTOR""",
    """NVFUSER""",
    """AOT_NVFUSER""",
    """AOT_CUDAGRAPHS""",
    """OFI""",
    """FX2TRT""",
    """ONNXRT""",
    """IPEX""",
]






def 							_lowerCAmelCase (  _a   :					Optional[int]					,   _a   :					int=None					,   _a   :					Union[str, Any]=None					,   _a   :					Optional[int]=None			)	->			Dict:
     lowerCAmelCase_					:       str    =		True
     while ask_again:
          lowerCAmelCase_					:       str    =		input(_a			)
          try:
               if default is not None and len(_a			) == 0:
                    return default
               return convert_value(_a			) if convert_value is not None else result
          except Exception:
               if error_message is not None:
                    print(_a			)






def 							_lowerCAmelCase (  _a   :					Any					,   _a   :					List[str]=[]					,   _a   :					List[str]=None					,   _a   :					int=0			)	->			Optional[int]:
     lowerCAmelCase_					:       Tuple    =		BulletMenu(_a					,   _a			)
     lowerCAmelCase_					:       str    =		menu.run(default_choice=_a			)
     return convert_value(_a			) if convert_value is not None else result






def 							_lowerCAmelCase (  _a   :					List[Any]			)	->			Any:
     lowerCAmelCase_					:       List[str]    =		int(_a			)
     return ComputeEnvironment(["""LOCAL_MACHINE""", """AMAZON_SAGEMAKER"""][value]			)






def 							_lowerCAmelCase (  _a   :					Optional[int]			)	->			int:
     lowerCAmelCase_					:       List[Any]    =		int(_a			)
     return DistributedType(["""NO""", """MULTI_CPU""", """MULTI_XPU""", """MULTI_GPU""", """MULTI_NPU""", """TPU"""][value]			)






def 							_lowerCAmelCase (  _a   :					List[str]			)	->			Dict:
     lowerCAmelCase_					:       Dict    =		int(_a			)
     return DynamoBackend(DYNAMO_BACKENDS[value]			).value






def 							_lowerCAmelCase (  _a   :					Union[str, Any]			)	->			Union[str, Any]:
     lowerCAmelCase_					:       Optional[int]    =		int(_a			)
     return PrecisionType(["""no""", """fp16""", """bf16""", """fp8"""][value]			)






def 							_lowerCAmelCase (  _a   :					int			)	->			str:
     lowerCAmelCase_					:       Dict    =		int(_a			)
     return SageMakerDistributedType(["""NO""", """DATA_PARALLEL""", """MODEL_PARALLEL"""][value]			)






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







class      lowercase__    (							argparse.RawDescriptionHelpFormatter  ):







  def 	UpperCAmelCase__		(	self    ,						_lowercase    ,						_lowercase    ,						_lowercase    ,						_lowercase						):
       lowerCAmelCase_					:       str    =		super()._format_usage(_lowercase    ,						_lowercase    ,						_lowercase    ,						_lowercase						)
       lowerCAmelCase_					:       List[str]    =		usage.replace("""<command> [<args>] """    ,						""""""						)
       return usage







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


UpperCAmelCase_					:   Dict 							=						{
    """configuration_poolformer""": [
        """POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """PoolFormerConfig""",
        """PoolFormerOnnxConfig""",
    ]
}

try:
      if not is_vision_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      UpperCAmelCase_					:   Union[str, Any] 							=						["""PoolFormerFeatureExtractor"""]
      UpperCAmelCase_					:   str 							=						["""PoolFormerImageProcessor"""]

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      UpperCAmelCase_					:   List[str] 							=						[
          """POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """PoolFormerForImageClassification""",
          """PoolFormerModel""",
          """PoolFormerPreTrainedModel""",
      ]


if TYPE_CHECKING:
      from .configuration_poolformer import (
          POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
          PoolFormerConfig,
          PoolFormerOnnxConfig,
      )

      try:
            if not is_vision_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .feature_extraction_poolformer import PoolFormerFeatureExtractor
            from .image_processing_poolformer import PoolFormerImageProcessor

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_poolformer import (
                POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
                PoolFormerForImageClassification,
                PoolFormerModel,
                PoolFormerPreTrainedModel,
            )


else:
      import sys

      UpperCAmelCase_					:   Optional[Any] 							=						_LazyModule(__name__, globals()["""__file__"""], _import_structure)
