




"""simple docstring"""
from collections import OrderedDict
from dataclasses import fields
from typing import Any, Tuple

import numpy as np

from .import_utils import is_torch_available






def 				__lowerCAmelCase					(					__lowerCAmelCase			:		List[str]						)    ->       Any:





 if is_torch_available():
  import torch

  if isinstance(_A  ,	torch.Tensor						):
   return True

 return isinstance(_A  ,	np.ndarray						)







class  _SCREAMING_SNAKE_CASE       (     SCREAMING_SNAKE_CASE__				):



 '''simple docstring'''





 def lowercase_      (self   ):

  '''simple docstring'''







  _UpperCamelCase      :	List[str]					      =  fields(self   )

  # Safety and consistency checks
  if not len(snake_case__   ):
   raise ValueError(F"{self.__class__.__name__} has no fields."   )

  _UpperCamelCase      :	List[str]					      =  getattr(self					,     class_fields[0].name   )
  _UpperCamelCase      :	List[Any]					      =  all(getattr(self					,     field.name   ) is None for field in class_fields[1:]   )

  if other_fields_are_none and isinstance(snake_case__					,     snake_case__   ):
   for key, value in first_field.items():
    _UpperCamelCase      :	Optional[int]					      =  value
  else:
   for field in class_fields:
    _UpperCamelCase      :	str					      =  getattr(self					,     field.name   )
    if v is not None:
     _UpperCamelCase      :	Optional[Any]					      =  v






 def __delitem__(self					,     *lowerCAmelCase__					,     **lowerCAmelCase__   ):

  '''simple docstring'''







  raise Exception(F"You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."   )






 def lowercase_      (self					,     *lowerCAmelCase__					,     **lowerCAmelCase__   ):

  '''simple docstring'''







  raise Exception(F"You cannot use ``setdefault`` on a {self.__class__.__name__} instance."   )






 def lowercase_      (self					,     *lowerCAmelCase__					,     **lowerCAmelCase__   ):

  '''simple docstring'''







  raise Exception(F"You cannot use ``pop`` on a {self.__class__.__name__} instance."   )






 def lowercase_      (self					,     *lowerCAmelCase__					,     **lowerCAmelCase__   ):

  '''simple docstring'''







  raise Exception(F"You cannot use ``update`` on a {self.__class__.__name__} instance."   )






 def __getitem__(self					,     lowerCAmelCase__   ):

  '''simple docstring'''







  if isinstance(snake_case__					,     snake_case__   ):
   _UpperCamelCase      :	Dict					      =  dict(self.items()   )
   return inner_dict[k]
  else:
   return self.to_tuple()[k]






 def __setattr__(self					,     lowerCAmelCase__					,     lowerCAmelCase__   ):

  '''simple docstring'''







  if name in self.keys() and value is not None:
   # Don't call self.__setitem__ to avoid recursion errors
   super().__setitem__(snake_case__					,     snake_case__   )
  super().__setattr__(snake_case__					,     snake_case__   )






 def __setitem__(self					,     lowerCAmelCase__					,     lowerCAmelCase__   ):

  '''simple docstring'''







  super().__setitem__(snake_case__					,     snake_case__   )
  # Don't call self.__setattr__ to avoid recursion errors
  super().__setattr__(snake_case__					,     snake_case__   )






 def lowercase_      (self   ):

  '''simple docstring'''







  return tuple(self[k] for k in self.keys()   )







'''simple docstring'''




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


_lowerCAmelCase	:		List[str]		  =						logging.get_logger(__name__)

_lowerCAmelCase	:		int		  =						{
    'facebook/opt-125m': 'https://huggingface.co/facebook/opt-125m/blob/main/config.json',
    'facebook/opt-350m': 'https://huggingface.co/facebook/opt-350m/blob/main/config.json',
    'facebook/opt-1.3b': 'https://huggingface.co/facebook/opt-1.3b/blob/main/config.json',
    'facebook/opt-2.7b': 'https://huggingface.co/facebook/opt-2.7b/blob/main/config.json',
    'facebook/opt-6.7b': 'https://huggingface.co/facebook/opt-6.7b/blob/main/config.json',
    'facebook/opt-13b': 'https://huggingface.co/facebook/opt-13b/blob/main/config.json',
}



class 			lowerCAmelCase					(					a				):
	_lowerCamelCase :       Dict         =			"""opt"""
	_lowerCamelCase :       Optional[Any]         =			["""past_key_values"""]



	def __init__(       self			,       snake_case__=5_0272			,       snake_case__=768			,       snake_case__=12			,       snake_case__=3072			,       snake_case__=2048			,       snake_case__=True			,       snake_case__=False			,       snake_case__=None			,       snake_case__=0.1			,       snake_case__=0.0			,       snake_case__=12			,       snake_case__="relu"			,       snake_case__=0.0			,       snake_case__=0.0_2			,       snake_case__=True			,       snake_case__=1			,       snake_case__=2			,       snake_case__=2			,       snake_case__=True			,       snake_case__=True			,       **snake_case__			,       ):
		super().__init__(
		    pad_token_id=snake_case__			,       bos_token_id=snake_case__			,       eos_token_id=snake_case__			,       **snake_case__			,       )
		lowerCAmelCase       :     Union[str, Any]   				=			vocab_size
		lowerCAmelCase       :     List[Any]   				=			max_position_embeddings
		lowerCAmelCase       :     List[str]   				=			num_attention_heads
		lowerCAmelCase       :     Dict   				=			word_embed_proj_dim if word_embed_proj_dim is not None else hidden_size
		lowerCAmelCase       :     Optional[Any]   				=			ffn_dim
		lowerCAmelCase       :     Optional[int]   				=			hidden_size
		lowerCAmelCase       :     List[str]   				=			num_hidden_layers
		lowerCAmelCase       :     Union[str, Any]   				=			dropout
		lowerCAmelCase       :     List[str]   				=			attention_dropout
		lowerCAmelCase       :     Union[str, Any]   				=			activation_function
		lowerCAmelCase       :     Optional[Any]   				=			init_std
		lowerCAmelCase       :     List[str]   				=			layerdrop
		lowerCAmelCase       :     Dict   				=			use_cache
		lowerCAmelCase       :     List[Any]   				=			do_layer_norm_before
		# We keep these variables at `True` for backward compatibility.
		lowerCAmelCase       :     List[str]   				=			enable_bias
		lowerCAmelCase       :     Dict   				=			layer_norm_elementwise_affine

		# Note that the only purpose of `_remove_final_layer_norm` is to keep backward compatibility
		# with checkpoints that have been fine-tuned before transformers v4.20.1
		# see https://github.com/facebookresearch/metaseq/pull/164
		lowerCAmelCase       :     Tuple   				=			_remove_final_layer_norm
