




"""simple docstring"""





import logging
import os
import threading
import time


try:
					import warnings
except ImportError:
					A   =       None

try:
					import msvcrt
except ImportError:
					A   =       None

try:
					import fcntl
except ImportError:
					A   =       None


# Backward compatibility
# ------------------------------------------------
try:
					TimeoutError
except NameError:
					A   =       OSError


# Data
# ------------------------------------------------
A   =       [
    """Timeout""",
    """BaseFileLock""",
    """WindowsFileLock""",
    """UnixFileLock""",
    """SoftFileLock""",
    """FileLock""",
]

A   =       """3.0.12"""


A   =       None

def 					_UpperCamelCase    (			)			->			Dict:


			"""simple docstring"""
			global _logger
			__UpperCAmelCase	: Union[str, Any]		=					_logger or logging.getLogger(__name__							)
			return _logger



class      a__				(	__magic_name__   ):


			def __init__(      self      :    List[Any]      ,  UpperCamelCase_      :    Any):


						"""simple docstring"""




						__UpperCAmelCase	: int		=					lock_file
						return None


			def __str__(      self      :    Any):


						"""simple docstring"""




						__UpperCAmelCase	: str		=					F"The file lock '{self.lock_file}' could not be acquired."
						return temp






class      a__				:


			def __init__(      self      :    str      ,  UpperCamelCase_      :    int):


						"""simple docstring"""




						__UpperCAmelCase	: Any		=					lock
						return None


			def __enter__(      self      :    Dict):


						"""simple docstring"""




						return self.lock


			def __exit__(      self      :    Any      ,  UpperCamelCase_      :    Optional[int]      ,  UpperCamelCase_      :    Tuple      ,  UpperCamelCase_      :    int):


						"""simple docstring"""




						self.lock.release()
						return None






class      a__				:


			def __init__(      self      :    Optional[Any]      ,  UpperCamelCase_      :    List[Any]      ,  UpperCamelCase_      :    List[str]=-1      ,  UpperCamelCase_      :    Dict=None):


						"""simple docstring"""




						__UpperCAmelCase	: List[str]		=					max_filename_length if max_filename_length is not None else 255
						# Hash the filename if it's too long
						__UpperCAmelCase	: Union[str, Any]		=					self.hash_filename_if_too_long(UpperCamelCase_      ,  UpperCamelCase_)
						# The path to the lock file.
						__UpperCAmelCase	: Optional[Any]		=					lock_file

						# The file descriptor for the *_lock_file* as it is returned by the
						# os.open() function.
						# This file lock is only NOT None, if the object currently holds the
						# lock.
						__UpperCAmelCase	: Dict		=					None

						# The default timeout value.
						__UpperCAmelCase	: Dict		=					timeout

						# We use this lock primarily for the lock counter.
						__UpperCAmelCase	: Any		=					threading.Lock()

						# The lock counter is used for implementing the nested locking
						# mechanism. Whenever the lock is acquired, the counter is increased and
						# the lock is only released, when this value is 0 again.
						__UpperCAmelCase	: Dict		=					0
						return None


			@property
			def       a_     (      self      :    Dict):


						"""simple docstring"""




						return self._lock_file


			@property
			def       a_     (      self      :    Optional[int]):


						"""simple docstring"""




						return self._timeout


			@timeout.setter
			def       a_     (      self      :    List[Any]      ,  UpperCamelCase_      :    Optional[Any]):


						"""simple docstring"""




						__UpperCAmelCase	: List[Any]		=					float(UpperCamelCase_)
						return None


			def       a_     (      self      :    Optional[int]):


						"""simple docstring"""




						raise NotImplementedError()


			def       a_     (      self      :    Dict):


						"""simple docstring"""




						raise NotImplementedError()


			@property
			def       a_     (      self      :    str):


						"""simple docstring"""




						return self._lock_file_fd is not None


			def       a_     (      self      :    Optional[Any]      ,  UpperCamelCase_      :    Any=None      ,  UpperCamelCase_      :    List[Any]=0.05):


						"""simple docstring"""




						if timeout is None:
									__UpperCAmelCase	: Dict		=					self.timeout

						# Increment the number right at the beginning.
						# We can still undo it, if something fails.
						with self._thread_lock:
									self._lock_counter += 1

						__UpperCAmelCase	: List[Any]		=					id(self)
						__UpperCAmelCase	: str		=					self._lock_file
						__UpperCAmelCase	: Optional[int]		=					time.time()
						try:
									while True:
												with self._thread_lock:
															if not self.is_locked:
																		logger().debug(F"Attempting to acquire lock {lock_id} on {lock_filename}")
																		self._acquire()

												if self.is_locked:
															logger().debug(F"Lock {lock_id} acquired on {lock_filename}")
															break
												elif timeout >= 0 and time.time() - start_time > timeout:
															logger().debug(F"Timeout on acquiring lock {lock_id} on {lock_filename}")
															raise Timeout(self._lock_file)
												else:
															logger().debug(
															    F"Lock {lock_id} not acquired on {lock_filename}, waiting {poll_intervall} seconds ...")
															time.sleep(UpperCamelCase_)
						except:  # noqa
									# Something did go wrong, so decrement the counter.
									with self._thread_lock:
												__UpperCAmelCase	: Tuple		=					max(0      ,  self._lock_counter - 1)

									raise
						return _Acquire_ReturnProxy(lock=self)


			def       a_     (      self      :    int      ,  UpperCamelCase_      :    Any=False):


						"""simple docstring"""




						with self._thread_lock:
									if self.is_locked:
												self._lock_counter -= 1

												if self._lock_counter == 0 or force:
															__UpperCAmelCase	: Union[str, Any]		=					id(self)
															__UpperCAmelCase	: Any		=					self._lock_file

															logger().debug(F"Attempting to release lock {lock_id} on {lock_filename}")
															self._release()
															__UpperCAmelCase	: str		=					0
															logger().debug(F"Lock {lock_id} released on {lock_filename}")

						return None


			def __enter__(      self      :    int):


						"""simple docstring"""




						self.acquire()
						return self


			def __exit__(      self      :    Union[str, Any]      ,  UpperCamelCase_      :    Union[str, Any]      ,  UpperCamelCase_      :    Any      ,  UpperCamelCase_      :    Optional[Any]):


						"""simple docstring"""




						self.release()
						return None


			def __del__(      self      :    Tuple):


						"""simple docstring"""




						self.release(force=UpperCamelCase_)
						return None


			def       a_     (      self      :    Tuple      ,  UpperCamelCase_      :    str      ,  UpperCamelCase_      :    int):


						"""simple docstring"""




						__UpperCAmelCase	: Union[str, Any]		=					os.path.basename(UpperCamelCase_)
						if len(UpperCamelCase_) > max_length and max_length > 0:
									__UpperCAmelCase	: Tuple		=					os.path.dirname(UpperCamelCase_)
									__UpperCAmelCase	: int		=					str(hash(UpperCamelCase_))
									__UpperCAmelCase	: Tuple		=					filename[: max_length - len(UpperCamelCase_) - 8] + "..." + hashed_filename + ".lock"
									return os.path.join(UpperCamelCase_      ,  UpperCamelCase_)
						else:
									return path






class      a__				(	__magic_name__   ):


			def __init__(      self      :    List[str]      ,  UpperCamelCase_      :    Optional[int]      ,  UpperCamelCase_      :    Union[str, Any]=-1      ,  UpperCamelCase_      :    List[Any]=None):


						"""simple docstring"""




						from .file_utils import relative_to_absolute_path

						super().__init__(UpperCamelCase_      ,  timeout=UpperCamelCase_      ,  max_filename_length=UpperCamelCase_)
						__UpperCAmelCase	: str		=					"\\\\?\\" + relative_to_absolute_path(self.lock_file)


			def       a_     (      self      :    Optional[int]):


						"""simple docstring"""




						__UpperCAmelCase	: Dict		=					os.O_RDWR | os.O_CREAT | os.O_TRUNC

						try:
									__UpperCAmelCase	: List[str]		=					os.open(self._lock_file      ,  UpperCamelCase_)
						except OSError:
									pass
						else:
									try:
												msvcrt.locking(UpperCamelCase_      ,  msvcrt.LK_NBLCK      ,  1)
									except OSError:
												os.close(UpperCamelCase_)
									else:
												__UpperCAmelCase	: List[Any]		=					fd
						return None


			def       a_     (      self      :    Tuple):


						"""simple docstring"""




						__UpperCAmelCase	: Any		=					self._lock_file_fd
						__UpperCAmelCase	: Optional[int]		=					None
						msvcrt.locking(UpperCamelCase_      ,  msvcrt.LK_UNLCK      ,  1)
						os.close(UpperCamelCase_)

						try:
									os.remove(self._lock_file)
						# Probably another instance of the application
						# that acquired the file lock.
						except OSError:
									pass
						return None






class      a__				(	__magic_name__   ):


			def __init__(      self      :    Union[str, Any]      ,  UpperCamelCase_      :    int      ,  UpperCamelCase_      :    Tuple=-1      ,  UpperCamelCase_      :    Tuple=None):


						"""simple docstring"""




						__UpperCAmelCase	: List[str]		=					os.statvfs(os.path.dirname(UpperCamelCase_)).f_namemax
						super().__init__(UpperCamelCase_      ,  timeout=UpperCamelCase_      ,  max_filename_length=UpperCamelCase_)


			def       a_     (      self      :    Any):


						"""simple docstring"""




						__UpperCAmelCase	: List[str]		=					os.O_RDWR | os.O_CREAT | os.O_TRUNC
						__UpperCAmelCase	: Optional[Any]		=					os.open(self._lock_file      ,  UpperCamelCase_)

						try:
									fcntl.flock(UpperCamelCase_      ,  fcntl.LOCK_EX | fcntl.LOCK_NB)
						except OSError:
									os.close(UpperCamelCase_)
						else:
									__UpperCAmelCase	: Dict		=					fd
						return None


			def       a_     (      self      :    str):


						"""simple docstring"""




						__UpperCAmelCase	: str		=					self._lock_file_fd
						__UpperCAmelCase	: str		=					None
						fcntl.flock(UpperCamelCase_      ,  fcntl.LOCK_UN)
						os.close(UpperCamelCase_)
						return None






class      a__				(	__magic_name__   ):


			def       a_     (      self      :    Any):


						"""simple docstring"""




						__UpperCAmelCase	: Optional[Any]		=					os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_TRUNC
						try:
									__UpperCAmelCase	: Optional[Any]		=					os.open(self._lock_file      ,  UpperCamelCase_)
						except OSError:
									pass
						else:
									__UpperCAmelCase	: Optional[int]		=					fd
						return None


			def       a_     (      self      :    Optional[Any]):


						"""simple docstring"""




						os.close(self._lock_file_fd)
						__UpperCAmelCase	: Optional[Any]		=					None

						try:
									os.remove(self._lock_file)
						# The file is already deleted and that's what we want.
						except OSError:
									pass
						return None






A   =       None

if msvcrt:
					A   =       WindowsFileLock
elif fcntl:
					A   =       UnixFileLock
else:
					A   =       SoftFileLock

					if warnings is not None:
										warnings.warn("""only soft file lock is available""")








"""simple docstring"""





from ...configuration_utils import PretrainedConfig
from ...utils import logging


A   =       logging.get_logger(__name__)

A   =       {
    """bigcode/gpt_bigcode-santacoder""": """https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json""",
}



class      a__				(	__magic_name__   ):
			lowercase_    =	"gpt_bigcode"
			lowercase_    =	["past_key_values"]
			lowercase_    =	{
			    "hidden_size": "n_embd",
			    "max_position_embeddings": "n_positions",
			    "num_attention_heads": "n_head",
			    "num_hidden_layers": "n_layer",
			}


			def __init__(      self      :    Any      ,  UpperCamelCase_      :    Tuple=50257      ,  UpperCamelCase_      :    Dict=1024      ,  UpperCamelCase_      :    Optional[Any]=768      ,  UpperCamelCase_      :    Optional[Any]=12      ,  UpperCamelCase_      :    Any=12      ,  UpperCamelCase_      :    Optional[int]=None      ,  UpperCamelCase_      :    List[Any]="gelu_pytorch_tanh"      ,  UpperCamelCase_      :    Optional[Any]=0.1      ,  UpperCamelCase_      :    Union[str, Any]=0.1      ,  UpperCamelCase_      :    Tuple=0.1      ,  UpperCamelCase_      :    Tuple=1e-5      ,  UpperCamelCase_      :    List[str]=0.02      ,  UpperCamelCase_      :    Dict=True      ,  UpperCamelCase_      :    Optional[int]=True      ,  UpperCamelCase_      :    str=50256      ,  UpperCamelCase_      :    Union[str, Any]=50256      ,  UpperCamelCase_      :    Dict=True      ,  UpperCamelCase_      :    List[str]=True      ,  UpperCamelCase_      :    Union[str, Any]=True      ,  **UpperCamelCase_      :    Union[str, Any]      ,  ):


						"""simple docstring"""




						__UpperCAmelCase	: Tuple		=					vocab_size
						__UpperCAmelCase	: Optional[int]		=					n_positions
						__UpperCAmelCase	: Tuple		=					n_embd
						__UpperCAmelCase	: str		=					n_layer
						__UpperCAmelCase	: Dict		=					n_head
						__UpperCAmelCase	: Optional[Any]		=					n_inner
						__UpperCAmelCase	: Optional[Any]		=					activation_function
						__UpperCAmelCase	: List[str]		=					resid_pdrop
						__UpperCAmelCase	: List[Any]		=					embd_pdrop
						__UpperCAmelCase	: Optional[Any]		=					attn_pdrop
						__UpperCAmelCase	: Dict		=					layer_norm_epsilon
						__UpperCAmelCase	: List[str]		=					initializer_range
						__UpperCAmelCase	: int		=					scale_attn_weights
						__UpperCAmelCase	: Tuple		=					use_cache
						__UpperCAmelCase	: List[Any]		=					attention_softmax_in_fpaa
						__UpperCAmelCase	: Any		=					scale_attention_softmax_in_fpaa
						__UpperCAmelCase	: str		=					multi_query

						__UpperCAmelCase	: int		=					bos_token_id
						__UpperCAmelCase	: str		=					eos_token_id

						super().__init__(bos_token_id=UpperCamelCase_      ,  eos_token_id=UpperCamelCase_      ,  **UpperCamelCase_)


