




import os

import pytest
import yaml

from datasets.features.features import Features, Value
from datasets.info import DatasetInfo, DatasetInfosDict


@pytest.mark.parametrize(
    '''files'''   ,				[
        ['''full:README.md''', '''dataset_infos.json'''],
        ['''empty:README.md''', '''dataset_infos.json'''],
        ['''dataset_infos.json'''],
        ['''full:README.md'''],
    ]   ,				)
def    A						(__A   :    Tuple   ,				__A   :    Dict       )   ->      Any:







     """simple docstring"""


     UpperCAmelCase_          =							tmp_path_factory.mktemp('''dset_infos_dir'''       )
     if "full:README.md" in files:
          with open(dataset_infos_dir / '''README.md'''   ,				'''w'''       ) as f:
               f.write('''---\ndataset_info:\n  dataset_size: 42\n---'''       )
     if "empty:README.md" in files:
          with open(dataset_infos_dir / '''README.md'''   ,				'''w'''       ) as f:
               f.write(''''''       )
    # we want to support dataset_infos.json for backward compatibility
     if "dataset_infos.json" in files:
          with open(dataset_infos_dir / '''dataset_infos.json'''   ,				'''w'''       ) as f:
               f.write('''{"default": {"dataset_size": 42}}'''       )
     UpperCAmelCase_          =							DatasetInfosDict.from_directory(__A       )
     assert dataset_infos
     assert dataset_infos["default"].dataset_size == 42


@pytest.mark.parametrize(
    '''dataset_info'''   ,				[
        DatasetInfo(),
        DatasetInfo(
            description='''foo'''   ,				features=Features({'''a''': Value('''int32'''       )}       )   ,				builder_name='''builder'''   ,				config_name='''config'''   ,				version='''1.0.0'''   ,				splits=[{'''name''': '''train'''}]   ,				download_size=42   ,				),
    ]   ,				)
def    A						(__A   :    Optional[int]   ,				__A   :    DatasetInfo       )   ->      Tuple:







     """simple docstring"""


     UpperCAmelCase_          =							str(__A       )
     dataset_info.write_to_directory(__A       )
     UpperCAmelCase_          =							DatasetInfo.from_directory(__A       )
     assert dataset_info == reloaded
     assert os.path.exists(os.path.join(__A   ,				'''dataset_info.json'''       )       )


def    A						()   ->      Optional[int]:







     """simple docstring"""


     UpperCAmelCase_          =							DatasetInfo(
         description='''foo'''   ,				citation='''bar'''   ,				homepage='''https://foo.bar'''   ,				license='''CC0'''   ,				features=Features({'''a''': Value('''int32'''       )}       )   ,				post_processed={}   ,				supervised_keys=()   ,				task_templates=[]   ,				builder_name='''builder'''   ,				config_name='''config'''   ,				version='''1.0.0'''   ,				splits=[{'''name''': '''train''', '''num_examples''': 42}]   ,				download_checksums={}   ,				download_size=1337   ,				post_processing_size=442   ,				dataset_size=1234   ,				size_in_bytes=1337 + 442 + 1234   ,				)
     UpperCAmelCase_          =							dataset_info._to_yaml_dict()
     assert sorted(__A       ) == sorted(DatasetInfo._INCLUDED_INFO_IN_YAML       )
     for key in DatasetInfo._INCLUDED_INFO_IN_YAML:
          assert key in dataset_info_yaml_dict
          assert isinstance(dataset_info_yaml_dict[key]   ,				(list, dict, int, str)       )
     UpperCAmelCase_          =							yaml.safe_dump(__A       )
     UpperCAmelCase_          =							yaml.safe_load(__A       )
     assert dataset_info_yaml_dict == reloaded


def    A						()   ->      Any:







     """simple docstring"""


     UpperCAmelCase_          =							DatasetInfo()
     UpperCAmelCase_          =							dataset_info._to_yaml_dict()
     assert dataset_info_yaml_dict == {}


@pytest.mark.parametrize(
    '''dataset_infos_dict'''   ,				[
        DatasetInfosDict(),
        DatasetInfosDict({'''default''': DatasetInfo()}       ),
        DatasetInfosDict({'''my_config_name''': DatasetInfo()}       ),
        DatasetInfosDict(
            {
                '''default''': DatasetInfo(
                    description='''foo'''   ,				features=Features({'''a''': Value('''int32'''       )}       )   ,				builder_name='''builder'''   ,				config_name='''config'''   ,				version='''1.0.0'''   ,				splits=[{'''name''': '''train'''}]   ,				download_size=42   ,				)
            }       ),
        DatasetInfosDict(
            {
                '''v1''': DatasetInfo(dataset_size=42       ),
                '''v2''': DatasetInfo(dataset_size=1337       ),
            }       ),
    ]   ,				)
def    A						(__A   :    Optional[Any]   ,				__A   :    DatasetInfosDict       )   ->      List[Any]:







     """simple docstring"""


     UpperCAmelCase_          =							str(__A       )
     dataset_infos_dict.write_to_directory(__A       )
     UpperCAmelCase_          =							DatasetInfosDict.from_directory(__A       )

     # the config_name of the dataset_infos_dict take over the attribute
     for config_name, dataset_info in dataset_infos_dict.items():
          UpperCAmelCase_          =							config_name
          # the yaml representation doesn't include fields like description or citation
          # so we just test that we can recover what we can from the yaml
          UpperCAmelCase_          =							DatasetInfo._from_yaml_dict(dataset_info._to_yaml_dict()       )
     assert dataset_infos_dict == reloaded

     if dataset_infos_dict:
          assert os.path.exists(os.path.join(__A   ,				'''README.md'''       )       )












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


snake_case_ : Any    		=       logging.get_logger(__name__)

snake_case_ : Optional[Any]    		=       {
    "tiiuae/falcon-40b": "https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json",
    "tiiuae/falcon-7b": "https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json",
}







class __snake_case			(			a		):
   UpperCAmelCase__  :    Optional[Any]          =  '''falcon'''
   UpperCAmelCase__  :    List[Any]          =  ['''past_key_values''']







   def __init__(      self		:						Union[str, Any]					,						_snake_case		:						List[str]=65024					,						_snake_case		:						int=4544					,						_snake_case		:						int=32					,						_snake_case		:						Any=71					,						_snake_case		:						int=1e-5					,						_snake_case		:						Dict=0.0_2					,						_snake_case		:						int=True					,						_snake_case		:						List[Any]=0.0					,						_snake_case		:						Tuple=0.0					,						_snake_case		:						int=None					,						_snake_case		:						Tuple=False					,						_snake_case		:						Any=False					,						_snake_case		:						str=True					,						_snake_case		:						Any=True					,						_snake_case		:						List[str]=False					,						_snake_case		:						Tuple=11					,						_snake_case		:						Dict=11					,						**_snake_case		:						Optional[int]					,						):

        """simple docstring"""


        UpperCAmelCase_          =							vocab_size
        # Backward compatibility with n_embed kwarg
        UpperCAmelCase_          =							kwargs.pop('''n_embed'''					,						_snake_case)
        UpperCAmelCase_          =							hidden_size if n_embed is None else n_embed
        UpperCAmelCase_          =							num_hidden_layers
        UpperCAmelCase_          =							num_attention_heads
        UpperCAmelCase_          =							layer_norm_epsilon
        UpperCAmelCase_          =							initializer_range
        UpperCAmelCase_          =							use_cache
        UpperCAmelCase_          =							hidden_dropout
        UpperCAmelCase_          =							attention_dropout

        UpperCAmelCase_          =							bos_token_id
        UpperCAmelCase_          =							eos_token_id
        UpperCAmelCase_          =							num_attention_heads if num_kv_heads is None else num_kv_heads
        UpperCAmelCase_          =							alibi
        UpperCAmelCase_          =							new_decoder_architecture
        UpperCAmelCase_          =							multi_query  # Ignored when new_decoder_architecture is True
        UpperCAmelCase_          =							parallel_attn
        UpperCAmelCase_          =							bias

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







   @property
   def lowerCamelCase						(      self		:						List[Any]):

        """simple docstring"""


        return self.hidden_size // self.num_attention_heads







   @property
   def lowerCamelCase						(      self		:						Union[str, Any]):

        """simple docstring"""


        return not self.alibi






