
'''simple docstring'''



def       lowerCAmelCase_		( SCREAMING_SNAKE_CASE_			,					SCREAMING_SNAKE_CASE_  )   ->   List[str]:




   """simple docstring"""
   sequence.append(SCREAMING_SNAKE_CASE_  )

   _SCREAMING_SNAKE_CASE          = 0
   while sequence[index] != target:
      index += 1

   sequence.pop()

   if index == len(SCREAMING_SNAKE_CASE_  ):
      return None

   return index


if __name__ == "__main__":
     UpperCamelCase__					:						str											=     input("Enter numbers separated by comma:\n").strip()
     UpperCamelCase__					:						str											=     [int(item) for item in user_input.split(",")]

     UpperCamelCase__					:						Union[str, Any]											=     input("Enter a single number to be found in the list:\n")
     UpperCamelCase__					:						Union[str, Any]											=     int(target_input)
     UpperCamelCase__					:						Tuple											=     sentinel_linear_search(sequence, target)
     if result is not None:
          print(f"""{target} found at positions: {result}""")
     else:
          print("Not found")







'''simple docstring'''




# 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 json
import os
from dataclasses import dataclass
from enum import Enum
from typing import List, Optional, Union

import yaml

from ...utils import ComputeEnvironment, DistributedType, SageMakerDistributedType
from ...utils.constants import SAGEMAKER_PYTHON_VERSION, SAGEMAKER_PYTORCH_VERSION, SAGEMAKER_TRANSFORMERS_VERSION


__snake_case   :      Union[str, Any]						    =  os.path.expanduser(
    os.getenv('HF_HOME', os.path.join(os.getenv('XDG_CACHE_HOME', '~/.cache'), 'huggingface'))
)
__snake_case   :      Union[str, Any]						    =  os.path.join(hf_cache_home, 'accelerate')
__snake_case   :      Any						    =  os.path.join(cache_dir, 'default_config.yaml')
__snake_case   :      Optional[Any]						    =  os.path.join(cache_dir, 'default_config.yaml')

# For backward compatibility: the default config is the json one if it's the only existing file.
if os.path.isfile(default_yaml_config_file) or not os.path.isfile(default_json_config_file):
  __snake_case   :      List[Any]						    =  default_yaml_config_file
else:
  __snake_case   :      Any						    =  default_json_config_file





def      _UpperCAmelCase    (							_UpperCamelCase    :	List[Any]   )	->      Any:
    if config_file is not None:
        if not os.path.isfile(_UpperCamelCase   ):
            raise FileNotFoundError(
                F'''The passed configuration file `{config_file}` does not exist. '''
                '''Please pass an existing file to `accelerate launch`, or use the the default one '''
                '''created through `accelerate config` and run `accelerate launch` '''
                '''without the `--config_file` argument.'''   )
    else:
        A_     =   default_config_file
    with open(_UpperCamelCase,   '''r''',   encoding='''utf-8'''   ) as f:
        if config_file.endswith('''.json'''   ):
            if (
                json.load(_UpperCamelCase   ).get('''compute_environment''',   ComputeEnvironment.LOCAL_MACHINE   )
                == ComputeEnvironment.LOCAL_MACHINE
            ):
                A_     =   ClusterConfig
            else:
                A_     =   SageMakerConfig
            return config_class.from_json_file(json_file=_UpperCamelCase   )
        else:
            if (
                yaml.safe_load(_UpperCamelCase   ).get('''compute_environment''',   ComputeEnvironment.LOCAL_MACHINE   )
                == ComputeEnvironment.LOCAL_MACHINE
            ):
                A_     =   ClusterConfig
            else:
                A_     =   SageMakerConfig
            return config_class.from_yaml_file(yaml_file=_UpperCamelCase   )




@dataclass
class 	__UpperCAmelCase				:





       '''simple docstring'''



       __lowercase					:					ComputeEnvironment
       __lowercase					:					Union[DistributedType, SageMakerDistributedType]
       __lowercase					:					str
       __lowercase					:					bool

       def 					__A       (      self )		->     Any:
           A_     =   self.__dict__
           # For serialization, it's best to convert Enums to strings (or their underlying value type).
           for key, value in result.items():
               if isinstance(_SCREAMING_SNAKE_CASE    ,     _SCREAMING_SNAKE_CASE ):
                   A_     =   value.value
               if isinstance(_SCREAMING_SNAKE_CASE    ,     _SCREAMING_SNAKE_CASE ) and not bool(_SCREAMING_SNAKE_CASE ):
                   A_     =   None
           A_     =   {k: v for k, v in result.items() if v is not None}
           return result

       @classmethod
       def 					__A       (      cls    ,     _SCREAMING_SNAKE_CASE=None )		->     Union[str, Any]:
           A_     =   default_json_config_file if json_file is None else json_file
           with open(_SCREAMING_SNAKE_CASE    ,     '''r'''    ,     encoding='''utf-8''' ) as f:
               A_     =   json.load(_SCREAMING_SNAKE_CASE )
           if "compute_environment" not in config_dict:
               A_     =   ComputeEnvironment.LOCAL_MACHINE
           if "mixed_precision" not in config_dict:
               A_     =   '''fp16''' if ('''fp16''' in config_dict and config_dict['''fp16''']) else None
           if "fp16" in config_dict:  # Convert the config to the new format.
               del config_dict["fp16"]
           if "dynamo_backend" in config_dict:  # Convert the config to the new format.
               A_     =   config_dict.pop('''dynamo_backend''' )
               A_     =   {} if dynamo_backend == '''NO''' else {'''dynamo_backend''': dynamo_backend}
           if "use_cpu" not in config_dict:
               A_     =   False
           return cls(**_SCREAMING_SNAKE_CASE )

       def 					__A       (      self    ,     _SCREAMING_SNAKE_CASE )		->     Union[str, Any]:
           with open(_SCREAMING_SNAKE_CASE    ,     '''w'''    ,     encoding='''utf-8''' ) as f:
               A_     =   json.dumps(self.to_dict()    ,     indent=2    ,     sort_keys=_SCREAMING_SNAKE_CASE ) + '''\n'''
               f.write(_SCREAMING_SNAKE_CASE )

       @classmethod
       def 					__A       (      cls    ,     _SCREAMING_SNAKE_CASE=None )		->     Optional[int]:
           A_     =   default_yaml_config_file if yaml_file is None else yaml_file
           with open(_SCREAMING_SNAKE_CASE    ,     '''r'''    ,     encoding='''utf-8''' ) as f:
               A_     =   yaml.safe_load(_SCREAMING_SNAKE_CASE )
           if "compute_environment" not in config_dict:
               A_     =   ComputeEnvironment.LOCAL_MACHINE

           if "mixed_precision" not in config_dict:
               A_     =   '''fp16''' if ('''fp16''' in config_dict and config_dict['''fp16''']) else None
           if isinstance(config_dict['''mixed_precision''']    ,     _SCREAMING_SNAKE_CASE ) and not config_dict["mixed_precision"]:
               A_     =   '''no'''
           if "fp16" in config_dict:  # Convert the config to the new format.
               del config_dict["fp16"]
           if "dynamo_backend" in config_dict:  # Convert the config to the new format.
               A_     =   config_dict.pop('''dynamo_backend''' )
               A_     =   {} if dynamo_backend == '''NO''' else {'''dynamo_backend''': dynamo_backend}
           if "use_cpu" not in config_dict:
               A_     =   False
           return cls(**_SCREAMING_SNAKE_CASE )

       def 					__A       (      self    ,     _SCREAMING_SNAKE_CASE )		->     int:
           with open(_SCREAMING_SNAKE_CASE    ,     '''w'''    ,     encoding='''utf-8''' ) as f:
               yaml.safe_dump(self.to_dict()    ,     _SCREAMING_SNAKE_CASE )

       def 					__A       (      self )		->     Tuple:
           if isinstance(self.compute_environment    ,     _SCREAMING_SNAKE_CASE ):
               A_     =   ComputeEnvironment(self.compute_environment )
           if isinstance(self.distributed_type    ,     _SCREAMING_SNAKE_CASE ):
               if self.compute_environment == ComputeEnvironment.AMAZON_SAGEMAKER:
                   A_     =   SageMakerDistributedType(self.distributed_type )
               else:
                   A_     =   DistributedType(self.distributed_type )
           if self.dynamo_config is None:
               A_     =   {}




@dataclass
class 	__UpperCAmelCase				(				_UpperCamelCase     ):





       '''simple docstring'''



       __lowercase					:					int
       __lowercase					:					int    =				0
       __lowercase					:					int    =				1
       __lowercase					:					Optional[str]    =				None
       __lowercase					:					Optional[str]    =				None
       __lowercase					:					Optional[int]    =				None
       __lowercase					:					Optional[str]    =				"static"
       __lowercase					:					Optional[bool]    =				False
       __lowercase					:					str    =				"main"

       # args for deepspeed_plugin
       __lowercase					:					dict    =				None
       # args for fsdp
       __lowercase					:					dict    =				None
       # args for megatron_lm
       __lowercase					:					dict    =				None
       # args for ipex
       __lowercase					:					dict    =				None
       # args for TPU
       __lowercase					:					bool    =				False

       # args for TPU pods
       __lowercase					:					str    =				None
       __lowercase					:					str    =				None
       __lowercase					:					bool    =				False
       __lowercase					:					bool    =				False
       __lowercase					:					str    =				None
       __lowercase					:					List[str]    =				None
       __lowercase					:					List[str]    =				None
       __lowercase					:					List[str]    =				None

       # args for dynamo
       __lowercase					:					dict    =				None

       def 					__A       (      self )		->     Any:
           if self.deepspeed_config is None:
               A_     =   {}
           if self.fsdp_config is None:
               A_     =   {}
           if self.megatron_lm_config is None:
               A_     =   {}
           if self.ipex_config is None:
               A_     =   {}
           return super().__post_init__()




@dataclass
class 	__UpperCAmelCase				(				_UpperCamelCase     ):





       '''simple docstring'''



       __lowercase					:					str
       __lowercase					:					str
       __lowercase					:					Optional[str]    =				None
       __lowercase					:					Optional[str]    =				None
       __lowercase					:					str    =				"us-east-1"
       __lowercase					:					int    =				1
       __lowercase					:					str    =				"all"
       __lowercase					:					str    =				f"accelerate-sagemaker-{num_machines}"
       __lowercase					:					str    =				SAGEMAKER_PYTORCH_VERSION
       __lowercase					:					str    =				SAGEMAKER_TRANSFORMERS_VERSION
       __lowercase					:					str    =				SAGEMAKER_PYTHON_VERSION
       __lowercase					:					str    =				None
       __lowercase					:					str    =				None
       __lowercase					:					dict    =				None
       __lowercase					:					dict    =				None






