





'''simple docstring'''





import json
import os
from pathlib import Path

import pytest

from datasets.download.download_config import DownloadConfig
from datasets.download.download_manager import DownloadManager
from datasets.utils.file_utils import hash_url_to_filename


__A             =       "http://www.mocksite.com/file1.txt"
__A             =       "\"text\": [\"foo\", \"foo\"]"
__A             =       "6d8ce9aa78a471c7477201efbeabd3bb01ac2e7d100a6dc024ba1608361f90a8"



class      _SCREAMING_SNAKE_CASE		:







 '''simple docstring'''
 lowercase_	=    200
 lowercase_	=    {"Content-Length": "100"}
 lowercase_	=    {}

 def 							SCREAMING_SNAKE_CASE_      (self       :     Optional[Any] ,				**UpperCAmelCase_       :     Union[str, Any]) ->Dict:



   '''simple docstring'''



   return [bytes(UpperCAmelCase_ ,				"utf-8")]





def   lowerCAmelCase_				( *__a			,					**__a	)  ->	Optional[Any]:







  """simple docstring"""





  return MockResponse()





@pytest.mark.parametrize("urls_type"			,					[str, list, dict]	)
def   lowerCAmelCase_				( __a			,					__a			,					__a	)  ->	str:







  """simple docstring"""





  import requests

  monkeypatch.setattr(__a			,					"request"			,					__a	)

  lowerCamelCase__:   Union[str, Any]    						=URL
  if issubclass(__a			,					__a	):
    lowerCamelCase__:   Optional[Any]    						=url
  elif issubclass(__a			,					__a	):
    lowerCamelCase__:   str    						=[url]
  elif issubclass(__a			,					__a	):
    lowerCamelCase__:   Union[str, Any]    						={"train": url}
  lowerCamelCase__:   Dict    						="dummy"
  lowerCamelCase__:   Optional[Any]    						="downloads"
  lowerCamelCase__:   Optional[int]    						=tmp_path
  lowerCamelCase__:   Any    						=DownloadConfig(
      cache_dir=os.path.join(__a			,					__a	)			,					use_etag=__a			,					)
  lowerCamelCase__:   List[str]    						=DownloadManager(dataset_name=__a			,					download_config=__a	)
  lowerCamelCase__:   Optional[int]    						=dl_manager.download(__a	)
  lowerCamelCase__:   List[Any]    						=urls
  for downloaded_paths in [downloaded_paths]:
    if isinstance(__a			,					__a	):
      lowerCamelCase__:   List[Any]    						=[downloaded_paths]
      lowerCamelCase__:   str    						=[urls]
    elif isinstance(__a			,					__a	):
      assert "train" in downloaded_paths.keys()
      lowerCamelCase__:   List[str]    						=downloaded_paths.values()
      lowerCamelCase__:   Dict    						=urls.values()
    assert downloaded_paths
    for downloaded_path, input_url in zip(__a			,					__a	):
      assert downloaded_path == dl_manager.downloaded_paths[input_url]
      lowerCamelCase__:   Union[str, Any]    						=Path(__a	)
      lowerCamelCase__:   Union[str, Any]    						=downloaded_path.parts
      assert parts[-1] == HASH
      assert parts[-2] == cache_subdir
      assert downloaded_path.exists()
      lowerCamelCase__:   List[str]    						=downloaded_path.read_text()
      assert content == CONTENT
      lowerCamelCase__:   List[Any]    						=downloaded_path.with_suffix(".json"	)
      assert metadata_downloaded_path.exists()
      lowerCamelCase__:   Union[str, Any]    						=json.loads(metadata_downloaded_path.read_text()	)
      assert metadata_content == {"url": URL, "etag": None}





@pytest.mark.parametrize("paths_type"			,					[str, list, dict]	)
def   lowerCAmelCase_				( __a			,					__a			,					__a	)  ->	int:







  """simple docstring"""





  lowerCamelCase__:   Tuple    						=str(__a	)
  if issubclass(__a			,					__a	):
    lowerCamelCase__:   int    						=filename
  elif issubclass(__a			,					__a	):
    lowerCamelCase__:   Optional[Any]    						=[filename]
  elif issubclass(__a			,					__a	):
    lowerCamelCase__:   Any    						={"train": filename}
  lowerCamelCase__:   Optional[int]    						="dummy"
  lowerCamelCase__:   str    						=xz_file.parent
  lowerCamelCase__:   Any    						="extracted"
  lowerCamelCase__:   Optional[int]    						=DownloadConfig(
      cache_dir=__a			,					use_etag=__a			,					)
  lowerCamelCase__:   Union[str, Any]    						=DownloadManager(dataset_name=__a			,					download_config=__a	)
  lowerCamelCase__:   List[Any]    						=dl_manager.extract(__a	)
  lowerCamelCase__:   Any    						=paths
  for extracted_paths in [extracted_paths]:
    if isinstance(__a			,					__a	):
      lowerCamelCase__:   Union[str, Any]    						=[extracted_paths]
      lowerCamelCase__:   List[Any]    						=[paths]
    elif isinstance(__a			,					__a	):
      assert "train" in extracted_paths.keys()
      lowerCamelCase__:   Union[str, Any]    						=extracted_paths.values()
      lowerCamelCase__:   int    						=paths.values()
    assert extracted_paths
    for extracted_path, input_path in zip(__a			,					__a	):
      assert extracted_path == dl_manager.extracted_paths[input_path]
      lowerCamelCase__:   Optional[Any]    						=Path(__a	)
      lowerCamelCase__:   Tuple    						=extracted_path.parts
      assert parts[-1] == hash_url_to_filename(__a			,					etag=__a	)
      assert parts[-2] == extracted_subdir
      assert extracted_path.exists()
      lowerCamelCase__:   Optional[int]    						=extracted_path.read_text()
      lowerCamelCase__:   int    						=text_file.read_text()
      assert extracted_file_content == expected_file_content





def   lowerCAmelCase_				( __a			,					__a	)  ->	Dict:







  """simple docstring"""





  assert path.endswith(".jsonl"	)
  for num_items, line in enumerate(__a			,					start=1	):
    lowerCamelCase__:   Dict    						=json.loads(line.decode("utf-8"	)	)
    assert item.keys() == {"col_1", "col_2", "col_3"}
  assert num_items == 4





@pytest.mark.parametrize("archive_jsonl"			,					["tar_jsonl_path", "zip_jsonl_path"]	)
def   lowerCAmelCase_				( __a			,					__a	)  ->	Union[str, Any]:







  """simple docstring"""





  lowerCamelCase__:   List[str]    						=request.getfixturevalue(__a	)
  lowerCamelCase__:   Tuple    						=DownloadManager()
  for num_jsonl, (path, file) in enumerate(dl_manager.iter_archive(__a	)			,					start=1	):
    _test_jsonl(__a			,					__a	)
  assert num_jsonl == 2





@pytest.mark.parametrize("archive_nested_jsonl"			,					["tar_nested_jsonl_path", "zip_nested_jsonl_path"]	)
def   lowerCAmelCase_				( __a			,					__a	)  ->	Tuple:







  """simple docstring"""





  lowerCamelCase__:   List[Any]    						=request.getfixturevalue(__a	)
  lowerCamelCase__:   str    						=DownloadManager()
  for num_tar, (path, file) in enumerate(dl_manager.iter_archive(__a	)			,					start=1	):
    for num_jsonl, (subpath, subfile) in enumerate(dl_manager.iter_archive(__a	)			,					start=1	):
      _test_jsonl(__a			,					__a	)
  assert num_tar == 1
  assert num_jsonl == 2






def   lowerCAmelCase_				( __a	)  ->	str:







  """simple docstring"""





  lowerCamelCase__:   List[Any]    						=DownloadManager()
  for num_file, file in enumerate(dl_manager.iter_files(__a	)			,					start=1	):
    assert os.path.basename(__a	) == ("test.txt" if num_file == 1 else "train.txt")
  assert num_file == 2








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


__A             =       logging.get_logger(__name__)

__A             =       {
    "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      _SCREAMING_SNAKE_CASE		(			__SCREAMING_SNAKE_CASE					):







 '''simple docstring'''
 lowercase_	=    "falcon"
 lowercase_	=    ["past_key_values"]

 def __init__(self       :     str ,				UpperCAmelCase_       :     Optional[Any]=65_024 ,				UpperCAmelCase_       :     Union[str, Any]=4_544 ,				UpperCAmelCase_       :     Any=32 ,				UpperCAmelCase_       :     str=71 ,				UpperCAmelCase_       :     int=1E-5 ,				UpperCAmelCase_       :     int=0.02 ,				UpperCAmelCase_       :     int=True ,				UpperCAmelCase_       :     Tuple=0.0 ,				UpperCAmelCase_       :     str=0.0 ,				UpperCAmelCase_       :     List[Any]=None ,				UpperCAmelCase_       :     Any=False ,				UpperCAmelCase_       :     Tuple=False ,				UpperCAmelCase_       :     List[Any]=True ,				UpperCAmelCase_       :     Dict=True ,				UpperCAmelCase_       :     List[str]=False ,				UpperCAmelCase_       :     str=11 ,				UpperCAmelCase_       :     List[Any]=11 ,				**UpperCAmelCase_       :     str ,				) ->Any:



   '''simple docstring'''



   lowerCamelCase__:   Dict    						=vocab_size
   # Backward compatibility with n_embed kwarg
   lowerCamelCase__:   List[Any]    						=kwargs.pop("n_embed" ,				UpperCAmelCase_)
   lowerCamelCase__:   Dict    						=hidden_size if n_embed is None else n_embed
   lowerCamelCase__:   Tuple    						=num_hidden_layers
   lowerCamelCase__:   Dict    						=num_attention_heads
   lowerCamelCase__:   Optional[Any]    						=layer_norm_epsilon
   lowerCamelCase__:   Union[str, Any]    						=initializer_range
   lowerCamelCase__:   Union[str, Any]    						=use_cache
   lowerCamelCase__:   str    						=hidden_dropout
   lowerCamelCase__:   Tuple    						=attention_dropout

   lowerCamelCase__:   Dict    						=bos_token_id
   lowerCamelCase__:   Union[str, Any]    						=eos_token_id
   lowerCamelCase__:   Any    						=num_attention_heads if num_kv_heads is None else num_kv_heads
   lowerCamelCase__:   Dict    						=alibi
   lowerCamelCase__:   Optional[Any]    						=new_decoder_architecture
   lowerCamelCase__:   List[str]    						=multi_query  # Ignored when new_decoder_architecture is True
   lowerCamelCase__:   Tuple    						=parallel_attn
   lowerCamelCase__:   Optional[Any]    						=bias

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

 @property
 def 							SCREAMING_SNAKE_CASE_      (self       :     List[Any]) ->Dict:



   '''simple docstring'''



   return self.hidden_size // self.num_attention_heads







 @property
 def 							SCREAMING_SNAKE_CASE_      (self       :     Dict) ->List[Any]:



   '''simple docstring'''



   return not self.alibi

