


import collections
import json
import os
import re
from typing import TYPE_CHECKING, List, Optional, Tuple

import numpy as np

from ...tokenization_utils_fast import PreTrainedTokenizer
from ...utils import logging


if TYPE_CHECKING:
 from transformers.pipelines.conversational import Conversation


SCREAMING_SNAKE_CASE			: Optional[Any]				   =					logging.get_logger(__name__)

SCREAMING_SNAKE_CASE			: List[Any]				   =					{"vocab_file": "vocab.txt", "emoji_file": "emoji.json"}

SCREAMING_SNAKE_CASE			: List[str]				   =					{
    "vocab_file": {
        "abeja/gpt-neox-japanese-2.7b": "https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/vocab.txt",
    },
    "emoji_file": {
        "abeja/gpt-neox-japanese-2.7b": "https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/emoji.json",
    },
}

SCREAMING_SNAKE_CASE			: Any				   =					{
    "abeja/gpt-neox-japanese-2.7b": 2048,
}



def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		Dict:
    with open(lowerCamelCase_				,					'r'				,					encoding='utf-8'					) as f:
        _lowercase			:				int 						=						json.loads(f.read()					)

    _lowercase			:				Optional[Any] 						=						collections.OrderedDict()
    _lowercase			:				Any 						=						collections.OrderedDict()
    _lowercase			:				Optional[Any] 						=						collections.OrderedDict()
    with open(lowerCamelCase_				,					'r'				,					encoding='utf-8'					) as f:
        _lowercase			:				List[str] 						=						f.readlines()
    _lowercase			:				List[str] 						=						[[t.rstrip('\n'					)] if (t == ',' or ',' not in t) else t.rstrip('\n'					).split(','					) for t in token]
    for idx, b in enumerate(lowerCamelCase_					):
        _lowercase			:				Optional[Any] 						=						b
        _lowercase			:				Dict 						=						idx
        for wd in b:
            _lowercase			:				Optional[int] 						=						idx

    return vocab, raw_vocab, ids_to_tokens, emoji






class _lowerCamelCase(		_a  ):
       lowercase_					:      str       					=     VOCAB_FILES_NAMES
       lowercase_					:      List[str]       					=     PRETRAINED_VOCAB_FILES_MAP
       lowercase_					:      Optional[Any]       					=     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       lowercase_					:      Union[str, Any]       					=     ["""input_ids""", """attention_mask"""]
       def __init__(   self, lowerCamelCase, lowerCamelCase, lowerCamelCase="<|endoftext|>", lowerCamelCase="<|endoftext|>", lowerCamelCase="<|startoftext|>", lowerCamelCase="<|endoftext|>", lowerCamelCase=False, **lowerCamelCase, )			->  Optional[int]:




           """simple docstring"""

           super().__init__(
               unk_token=lowerCamelCase, pad_token=lowerCamelCase, bos_token=lowerCamelCase, eos_token=lowerCamelCase, do_clean_text=lowerCamelCase, **lowerCamelCase, )
           if not os.path.isfile(lowerCamelCase):
               raise ValueError(
                   F'''Can\'t find a vocabulary file at path \'{vocab_file}\'. To load the vocabulary from a Google pretrained'''
                   ' model use `tokenizer = GPTNeoXJapaneseokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`')
           if not os.path.isfile(lowerCamelCase):
               raise ValueError(
                   F'''Can\'t find a emoji file at path \'{emoji_file}\'. To load the emoji information from a Google'''
                   ' pretrained model use `tokenizer = GPTNeoXJapaneseokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`')
           _lowercase			:				Tuple 						=						do_clean_text
           _lowercase						,							_lowercase						,							_lowercase						,							_lowercase			:				Dict 						=						load_vocab_and_emoji(lowerCamelCase, lowerCamelCase)
           _lowercase			:				str 						=						SubWordJapaneseTokenizer(
               vocab=self.vocab, ids_to_tokens=self.ids_to_tokens, emoji=self.emoji)
       @property
       def      UpperCamelCase	(   self)			->  Optional[int]:




           """simple docstring"""

           return len(self.raw_vocab)
       def      UpperCamelCase	(   self)			->  List[str]:




           """simple docstring"""

           return dict(self.raw_vocab, **self.added_tokens_encoder)
       def      UpperCamelCase	(   self, lowerCamelCase)			->  Optional[Any]:




           """simple docstring"""

           return self.subword_tokenizer.tokenize(lowerCamelCase, clean=self.do_clean_text)
       def      UpperCamelCase	(   self, lowerCamelCase)			->  Tuple:




           """simple docstring"""

           return self.vocab.get(lowerCamelCase, self.vocab.get(self.unk_token))
       def      UpperCamelCase	(   self, lowerCamelCase)			->  Tuple:




           """simple docstring"""

           return self.subword_tokenizer.convert_id_to_token(lowerCamelCase)
       def      UpperCamelCase	(   self, lowerCamelCase)			->  Optional[int]:




           """simple docstring"""

           _lowercase			:				str 						=						''.join(lowerCamelCase).strip()
           return out_string
       def      UpperCamelCase	(   self, lowerCamelCase)			->  List[int]:




           """simple docstring"""

           _lowercase			:				str 						=						[]
           for is_user, text in conversation.iter_texts():
               input_ids.extend(self.encode(lowerCamelCase, add_special_tokens=lowerCamelCase) + [self.eos_token_id])

           if len(lowerCamelCase) > self.model_max_length:
               _lowercase			:				List[str] 						=						input_ids[-self.model_max_length :]
           return input_ids




       def      UpperCamelCase	(   self, lowerCamelCase, lowerCamelCase = None)			->  Tuple[str]:




           """simple docstring"""

           _lowercase			:				Tuple 						=						0
           if os.path.isdir(lowerCamelCase):
               _lowercase			:				int 						=						os.path.join(
                   lowerCamelCase, (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file'])
               _lowercase			:				Union[str, Any] 						=						os.path.join(
                   lowerCamelCase, (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['emoji_file'])
           else:
               _lowercase			:				Dict 						=						(
                   (filename_prefix + '-' if filename_prefix else '') + save_directory + VOCAB_FILES_NAMES['vocab_file']
               )
               _lowercase			:				str 						=						(
                   (filename_prefix + '-' if filename_prefix else '') + save_directory + VOCAB_FILES_NAMES['emoji_file']
               )
           with open(lowerCamelCase, 'w', encoding='utf-8') as writer:
               for token_index, token in self.ids_to_tokens.items():
                   if index != token_index:
                       logger.warning(
                           F'''Saving vocabulary to {vocab_file}: vocabulary indices are not consecutive.'''
                           ' Please check that the vocabulary is not corrupted!')
                       _lowercase			:				Union[str, Any] 						=						token_index
                   writer.write(','.join(lowerCamelCase) + '\n')
                   index += 1
           with open(lowerCamelCase, 'w', encoding='utf-8') as writer:
               json.dump(self.emoji, lowerCamelCase)
           return vocab_file, emoji_file






class _lowerCamelCase(		_a  ):
       def __init__(   self, lowerCamelCase, lowerCamelCase, lowerCamelCase)			->  List[Any]:




           """simple docstring"""

           _lowercase			:				List[Any] 						=						vocab  # same as swe
           _lowercase			:				int 						=						ids_to_tokens  # same as bpe
           _lowercase			:				Tuple 						=						emoji
           _lowercase			:				Tuple 						=						np.max([len(lowerCamelCase) for w in self.vocab.keys()])
           _lowercase			:				Dict 						=						re.compile(R'(https?|ftp)(:\/\/[-_\.!~*\'()a-zA-Z0-9;\/?:\@&=\+$,%#]+)')
           _lowercase			:				Tuple 						=						re.compile(R'[A-Za-z0-9\._+]*@[\-_0-9A-Za-z]+(\.[A-Za-z]+)*')
           _lowercase			:				List[Any] 						=						re.compile(R'[\(]{0,1}[0-9]{2,4}[\)\-\(]{0,1}[0-9]{2,4}[\)\-]{0,1}[0-9]{3,4}')
           _lowercase			:				Union[str, Any] 						=						re.compile(
               R'([12]\d{3}[/\-年])*(0?[1-9]|1[0-2])[/\-月]((0?[1-9]|[12][0-9]|3[01])日?)*(\d{1,2}|:|\d{1,2}時|\d{1,2}分|\(日\)|\(月\)|\(火\)|\(水\)|\(木\)|\(金\)|\(土\)|㈰|㈪|㈫|㈬|㈭|㈮|㈯)*')
           _lowercase			:				List[Any] 						=						re.compile(
               R'(明治|大正|昭和|平成|令和|㍾|㍽|㍼|㍻|\u32ff)\d{1,2}年(0?[1-9]|1[0-2])月(0?[1-9]|[12][0-9]|3[01])日(\d{1,2}|:|\d{1,2}時|\d{1,2}分|\(日\)|\(月\)|\(火\)|\(水\)|\(木\)|\(金\)|\(土\)|㈰|㈪|㈫|㈬|㈭|㈮|㈯)*')
           _lowercase			:				Optional[Any] 						=						re.compile(
               R'((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*億)*((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*万)*((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*千)*(0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*(千円|万円|千万円|円|千ドル|万ドル|千万ドル|ドル|千ユーロ|万ユーロ|千万ユーロ|ユーロ)+(\(税込\)|\(税抜\)|\+tax)*')
           _lowercase			:				List[str] 						=						'─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿'
           _lowercase			:				int 						=						'▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟'
           _lowercase			:				str 						=						str.maketrans({k: '<BLOCK>' for k in keisen + blocks})
       def __len__(   self)			->  List[str]:




           """simple docstring"""

           return len(self.ids_to_tokens)
       def      UpperCamelCase	(   self, lowerCamelCase)			->  Tuple:




           """simple docstring"""

           _lowercase			:				Union[str, Any] 						=						self.content_repattera.sub('<URL>', lowerCamelCase)
           _lowercase			:				Dict 						=						self.content_repattera.sub('<EMAIL>', lowerCamelCase)
           _lowercase			:				List[str] 						=						self.content_repattera.sub('<TEL>', lowerCamelCase)
           _lowercase			:				Optional[int] 						=						self.content_repattera.sub('<DATE>', lowerCamelCase)
           _lowercase			:				Tuple 						=						self.content_repattera.sub('<DATE>', lowerCamelCase)
           _lowercase			:				str 						=						self.content_repattera.sub('<PRICE>', lowerCamelCase)
           _lowercase			:				int 						=						content.translate(self.content_transa)
           while "<BLOCK><BLOCK>" in content:
               _lowercase			:				Optional[Any] 						=						content.replace('<BLOCK><BLOCK>', '<BLOCK>')
           return content
       def      UpperCamelCase	(   self, lowerCamelCase, lowerCamelCase=False)			->  List[Any]:




           """simple docstring"""

           _lowercase			:				int 						=						text.replace(' ', '<SP>')
           _lowercase			:				Optional[Any] 						=						text.replace('　', '<SP>')
           _lowercase			:				Tuple 						=						text.replace('\r\n', '<BR>')
           _lowercase			:				Tuple 						=						text.replace('\n', '<BR>')
           _lowercase			:				Dict 						=						text.replace('\r', '<BR>')
           _lowercase			:				str 						=						text.replace('\t', '<TAB>')
           _lowercase			:				Optional[Any] 						=						text.replace('—', 'ー')
           _lowercase			:				Union[str, Any] 						=						text.replace('−', 'ー')
           for k, v in self.emoji["emoji"].items():
               if k in text:
                   _lowercase			:				Optional[int] 						=						text.replace(lowerCamelCase, lowerCamelCase)
           if clean:
               _lowercase			:				Tuple 						=						self.clean_text(lowerCamelCase)

           def check_simbol(lowerCamelCase):
               _lowercase			:				Optional[int] 						=						x.encode()
               if len(lowerCamelCase) == 1 and len(lowerCamelCase) == 2:
                   _lowercase			:				List[Any] 						=						(int(e[0]) << 8) + int(e[1])
                   if (
                       (c >= 0xC2A1 and c <= 0xC2BF)
                       or (c >= 0xC780 and c <= 0xC783)
                       or (c >= 0xCAB9 and c <= 0xCBBF)
                       or (c >= 0xCC80 and c <= 0xCDA2)
                   ):
                       return True
               return False

           def checkuae(lowerCamelCase):
               _lowercase			:				int 						=						x.encode()
               if len(lowerCamelCase) == 1 and len(lowerCamelCase) == 3:
                   _lowercase			:				Optional[Any] 						=						(int(e[0]) << 16) + (int(e[1]) << 8) + int(e[2])
                   if c >= 0xE28080 and c <= 0xE2B07F:
                       return True
               return False

           _lowercase			:				Dict 						=						0
           _lowercase			:				Optional[int] 						=						[]
           while pos < len(lowerCamelCase):
               _lowercase			:				Optional[Any] 						=						min(len(lowerCamelCase), pos + self.maxlen + 1) if text[pos] == '<' else pos + 3
               _lowercase			:				Optional[int] 						=						[]  # (token_id, token, pos)
               for e in range(lowerCamelCase, lowerCamelCase, -1):
                   _lowercase			:				Optional[Any] 						=						text[pos:e]
                   if wd in self.vocab:
                       if wd[0] == "<" and len(lowerCamelCase) > 2:
                           _lowercase			:				List[Any] 						=						[(self.vocab[wd], wd, e)]
                           break
                       else:
                           candidates.append((self.vocab[wd], wd, e))
               if len(lowerCamelCase) > 0:
                   # the smallest token_id is adopted
                   _lowercase						,							_lowercase						,							_lowercase			:				List[str] 						=						sorted(lowerCamelCase, key=lambda lowerCamelCase: x[0])[0]
                   result.append(lowerCamelCase)
                   _lowercase			:				List[str] 						=						e
               else:
                   _lowercase			:				Optional[int] 						=						pos + 1
                   _lowercase			:				int 						=						text[pos:end]
                   if check_simbol(lowerCamelCase):
                       result.append('<KIGOU>')
                   elif checkuae(lowerCamelCase):
                       result.append('<U2000U2BFF>')
                   else:
                       for i in wd.encode('utf-8'):
                           result.append('<|byte%d|>' % i)
                   _lowercase			:				Optional[Any] 						=						end
           return result




       def      UpperCamelCase	(   self, lowerCamelCase, lowerCamelCase="\n")			->  List[str]:




           """simple docstring"""

           _lowercase			:				List[Any] 						=						[]
           _lowercase			:				str 						=						[]
           _lowercase			:				str 						=						self.ids_to_tokens[index][0]
           if word[:6] == "<|byte" and word[-2:] == "|>":
               byte_tokens.append(int(word[6:-2]))
           else:
               if len(lowerCamelCase) > 0:
                   words.append(bytearray(lowerCamelCase).decode('utf-8', errors='replace'))
                   _lowercase			:				Optional[Any] 						=						[]
               if word[:7] == "<|emoji" and word[-2:] == "|>":
                   words.append(self.emoji['emoji_inv'][word])
               elif word == "<SP>":
                   words.append(' ')
               elif word == "<BR>":
                   words.append(lowerCamelCase)
               elif word == "<TAB>":
                   words.append('\t')
               elif word == "<BLOCK>":
                   words.append('▀')
               elif word == "<KIGOU>":
                   words.append('ǀ')
               elif word == "<U2000U2BFF>":
                   words.append('‖')
               else:
                   words.append(lowerCamelCase)
           if len(lowerCamelCase) > 0:
               words.append(bytearray(lowerCamelCase).decode('utf-8', errors='replace'))
           _lowercase			:				Union[str, Any] 						=						''.join(lowerCamelCase)
           return text






import contextlib
import csv
import json
import os
import sqlitea
import tarfile
import textwrap
import zipfile

import pyarrow as pa
import pyarrow.parquet as pq
import pytest

import datasets
import datasets.config



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( )       ->		Any:
    _lowercase			:				str 						=						10
    _lowercase			:				List[str] 						=						datasets.Features(
        {
            'tokens': datasets.Sequence(datasets.Value('string'					)					),
            'labels': datasets.Sequence(datasets.ClassLabel(names=['negative', 'positive']					)					),
            'answers': datasets.Sequence(
                {
                    'text': datasets.Value('string'					),
                    'answer_start': datasets.Value('int32'					),
                }					),
            'id': datasets.Value('int64'					),
        }					)
    _lowercase			:				Union[str, Any] 						=						datasets.Dataset.from_dict(
        {
            'tokens': [['foo'] * 5] * n,
            'labels': [[1] * 5] * n,
            'answers': [{'answer_start': [97], 'text': ['1976']}] * 10,
            'id': list(range(lowerCamelCase_					)					),
        }				,					features=lowerCamelCase_				,					)
    return dataset



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		int:
    _lowercase			:				int 						=						str(tmp_path_factory.mktemp('data'					) / 'file.arrow'					)
    dataset.map(cache_file_name=lowerCamelCase_					)
    return filename


# FILE_CONTENT + files


SCREAMING_SNAKE_CASE			: str				   =					"\\n    Text data.\n    Second line of data."



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		List[Any]:
    _lowercase			:				str 						=						tmp_path_factory.mktemp('data'					) / 'file.txt'
    _lowercase			:				List[str] 						=						FILE_CONTENT
    with open(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_					)
    return filename



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Tuple:
    import bza

    _lowercase			:				Any 						=						tmp_path_factory.mktemp('data'					) / 'file.txt.bz2'
    _lowercase			:				Optional[Any] 						=						bytes(lowerCamelCase_				,					'utf-8'					)
    with bza.open(lowerCamelCase_				,					'wb'					) as f:
        f.write(lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		List[Any]:
    import gzip

    _lowercase			:				Optional[int] 						=						str(tmp_path_factory.mktemp('data'					) / 'file.txt.gz'					)
    _lowercase			:				Optional[int] 						=						bytes(lowerCamelCase_				,					'utf-8'					)
    with gzip.open(lowerCamelCase_				,					'wb'					) as f:
        f.write(lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		str:
    if datasets.config.LZ4_AVAILABLE:
        import lza.frame

        _lowercase			:				Any 						=						tmp_path_factory.mktemp('data'					) / 'file.txt.lz4'
        _lowercase			:				Optional[Any] 						=						bytes(lowerCamelCase_				,					'utf-8'					)
        with lza.frame.open(lowerCamelCase_				,					'wb'					) as f:
            f.write(lowerCamelCase_					)
        return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		str:
    if datasets.config.PY7ZR_AVAILABLE:
        import pyazr

        _lowercase			:				int 						=						tmp_path_factory.mktemp('data'					) / 'file.txt.7z'
        with pyazr.SevenZipFile(lowerCamelCase_				,					'w'					) as archive:
            archive.write(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
        return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		List[str]:
    import tarfile

    _lowercase			:				Optional[Any] 						=						tmp_path_factory.mktemp('data'					) / 'file.txt.tar'
    with tarfile.TarFile(lowerCamelCase_				,					'w'					) as f:
        f.add(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		str:
    import lzma

    _lowercase			:				Optional[Any] 						=						tmp_path_factory.mktemp('data'					) / 'file.txt.xz'
    _lowercase			:				int 						=						bytes(lowerCamelCase_				,					'utf-8'					)
    with lzma.open(lowerCamelCase_				,					'wb'					) as f:
        f.write(lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		str:
    import zipfile

    _lowercase			:				Dict 						=						tmp_path_factory.mktemp('data'					) / 'file.txt.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Optional[Any]:
    if datasets.config.ZSTANDARD_AVAILABLE:
        import zstandard as zstd

        _lowercase			:				Optional[Any] 						=						tmp_path_factory.mktemp('data'					) / 'file.txt.zst'
        _lowercase			:				Dict 						=						bytes(lowerCamelCase_				,					'utf-8'					)
        with zstd.open(lowerCamelCase_				,					'wb'					) as f:
            f.write(lowerCamelCase_					)
        return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		str:
    _lowercase			:				Union[str, Any] 						=						tmp_path_factory.mktemp('data'					) / 'file.xml'
    _lowercase			:				Optional[Any] 						=						textwrap.dedent(
        '\\n    <?xml version="1.0" encoding="UTF-8" ?>\n    <tmx version="1.4">\n      <header segtype="sentence" srclang="ca" />\n      <body>\n        <tu>\n          <tuv xml:lang="ca"><seg>Contingut 1</seg></tuv>\n          <tuv xml:lang="en"><seg>Content 1</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang="ca"><seg>Contingut 2</seg></tuv>\n          <tuv xml:lang="en"><seg>Content 2</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang="ca"><seg>Contingut 3</seg></tuv>\n          <tuv xml:lang="en"><seg>Content 3</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang="ca"><seg>Contingut 4</seg></tuv>\n          <tuv xml:lang="en"><seg>Content 4</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang="ca"><seg>Contingut 5</seg></tuv>\n          <tuv xml:lang="en"><seg>Content 5</seg></tuv>\n        </tu>\n      </body>\n    </tmx>'					)
    with open(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_					)
    return filename


SCREAMING_SNAKE_CASE			: Dict				   =					[
    {"col_1": "0", "col_2": 0, "col_3": 0.0},
    {"col_1": "1", "col_2": 1, "col_3": 1.0},
    {"col_1": "2", "col_2": 2, "col_3": 2.0},
    {"col_1": "3", "col_2": 3, "col_3": 3.0},
]
SCREAMING_SNAKE_CASE			: Dict				   =					[
    {"col_1": "4", "col_2": 4, "col_3": 4.0},
    {"col_1": "5", "col_2": 5, "col_3": 5.0},
]
SCREAMING_SNAKE_CASE			: Optional[Any]				   =					{
    "col_1": ["0", "1", "2", "3"],
    "col_2": [0, 1, 2, 3],
    "col_3": [0.0, 1.0, 2.0, 3.0],
}

SCREAMING_SNAKE_CASE			: Tuple				   =					[
    {"col_3": 0.0, "col_1": "0", "col_2": 0},
    {"col_3": 1.0, "col_1": "1", "col_2": 1},
]

SCREAMING_SNAKE_CASE			: Any				   =					[
    {"col_1": "s0", "col_2": 0, "col_3": 0.0},
    {"col_1": "s1", "col_2": 1, "col_3": 1.0},
    {"col_1": "s2", "col_2": 2, "col_3": 2.0},
    {"col_1": "s3", "col_2": 3, "col_3": 3.0},
]



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( )       ->		List[str]:
    return DATA_DICT_OF_LISTS



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Dict:
    _lowercase			:				Optional[int] 						=						datasets.Dataset.from_dict(lowerCamelCase_					)
    _lowercase			:				List[Any] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.arrow'					)
    dataset.map(cache_file_name=lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		str:
    _lowercase			:				List[str] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.sqlite'					)
    with contextlib.closing(sqlitea.connect(lowerCamelCase_					)					) as con:
        _lowercase			:				Union[str, Any] 						=						con.cursor()
        cur.execute('CREATE TABLE dataset(col_1 text, col_2 int, col_3 real)'					)
        for item in DATA:
            cur.execute('INSERT INTO dataset(col_1, col_2, col_3) VALUES (?, ?, ?)'				,					tuple(item.values()					)					)
        con.commit()
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Dict:
    _lowercase			:				List[str] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.csv'					)
    with open(lowerCamelCase_				,					'w'				,					newline=''					) as f:
        _lowercase			:				Tuple 						=						csv.DictWriter(lowerCamelCase_				,					fieldnames=['col_1', 'col_2', 'col_3']					)
        writer.writeheader()
        for item in DATA:
            writer.writerow(lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		List[Any]:
    _lowercase			:				Tuple 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset2.csv'					)
    with open(lowerCamelCase_				,					'w'				,					newline=''					) as f:
        _lowercase			:				str 						=						csv.DictWriter(lowerCamelCase_				,					fieldnames=['col_1', 'col_2', 'col_3']					)
        writer.writeheader()
        for item in DATA:
            writer.writerow(lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		Any:
    import bza

    _lowercase			:				int 						=						tmp_path_factory.mktemp('data'					) / 'dataset.csv.bz2'
    with open(lowerCamelCase_				,					'rb'					) as f:
        _lowercase			:				int 						=						f.read()
    # data = bytes(FILE_CONTENT, "utf-8")
    with bza.open(lowerCamelCase_				,					'wb'					) as f:
        f.write(lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Optional[int]:
    _lowercase			:				Optional[Any] 						=						tmp_path_factory.mktemp('data'					) / 'dataset.csv.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
        f.write(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Optional[Any]:
    _lowercase			:				str 						=						tmp_path_factory.mktemp('data'					) / 'dataset.csv.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.basename(csv_path.replace('.csv'				,					'.CSV'					)					)					)
        f.write(lowerCamelCase_				,					arcname=os.path.basename(csva_path.replace('.csv'				,					'.CSV'					)					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Union[str, Any]:
    _lowercase			:				Union[str, Any] 						=						tmp_path_factory.mktemp('data'					) / 'dataset_with_dir.csv.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.join('main_dir'				,					os.path.basename(lowerCamelCase_					)					)					)
        f.write(lowerCamelCase_				,					arcname=os.path.join('main_dir'				,					os.path.basename(lowerCamelCase_					)					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		int:
    _lowercase			:				Optional[int] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.parquet'					)
    _lowercase			:				Optional[Any] 						=						pa.schema(
        {
            'col_1': pa.string(),
            'col_2': pa.intaa(),
            'col_3': pa.floataa(),
        }					)
    with open(lowerCamelCase_				,					'wb'					) as f:
        _lowercase			:				List[str] 						=						pq.ParquetWriter(lowerCamelCase_				,					schema=lowerCamelCase_					)
        _lowercase			:				Any 						=						pa.Table.from_pydict({k: [DATA[i][k] for i in range(len(lowerCamelCase_					)					)] for k in DATA[0]}				,					schema=lowerCamelCase_					)
        writer.write_table(lowerCamelCase_					)
        writer.close()
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Optional[Any]:
    _lowercase			:				Optional[Any] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.json'					)
    _lowercase			:				List[Any] 						=						{'data': DATA}
    with open(lowerCamelCase_				,					'w'					) as f:
        json.dump(lowerCamelCase_				,					lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Any:
    _lowercase			:				Tuple 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.json'					)
    _lowercase			:				Optional[Any] 						=						{'data': DATA_DICT_OF_LISTS}
    with open(lowerCamelCase_				,					'w'					) as f:
        json.dump(lowerCamelCase_				,					lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Union[str, Any]:
    _lowercase			:				Any 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.jsonl'					)
    with open(lowerCamelCase_				,					'w'					) as f:
        for item in DATA:
            f.write(json.dumps(lowerCamelCase_					) + '\n'					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Dict:
    _lowercase			:				Dict 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset2.jsonl'					)
    with open(lowerCamelCase_				,					'w'					) as f:
        for item in DATA:
            f.write(json.dumps(lowerCamelCase_					) + '\n'					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		List[str]:
    _lowercase			:				Optional[Any] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset_312.jsonl'					)
    with open(lowerCamelCase_				,					'w'					) as f:
        for item in DATA_312:
            f.write(json.dumps(lowerCamelCase_					) + '\n'					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		List[Any]:
    _lowercase			:				str 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset-str.jsonl'					)
    with open(lowerCamelCase_				,					'w'					) as f:
        for item in DATA_STR:
            f.write(json.dumps(lowerCamelCase_					) + '\n'					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		Optional[Any]:
    import gzip

    _lowercase			:				Tuple 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.txt.gz'					)
    with open(lowerCamelCase_				,					'rb'					) as orig_file:
        with gzip.open(lowerCamelCase_				,					'wb'					) as zipped_file:
            zipped_file.writelines(lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		Dict:
    import gzip

    _lowercase			:				Optional[int] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.jsonl.gz'					)
    with open(lowerCamelCase_				,					'rb'					) as orig_file:
        with gzip.open(lowerCamelCase_				,					'wb'					) as zipped_file:
            zipped_file.writelines(lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		List[str]:
    _lowercase			:				Any 						=						tmp_path_factory.mktemp('data'					) / 'dataset.jsonl.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
        f.write(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		str:
    _lowercase			:				str 						=						tmp_path_factory.mktemp('data'					) / 'dataset_nested.jsonl.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.join('nested'				,					os.path.basename(lowerCamelCase_					)					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		int:
    _lowercase			:				Optional[Any] 						=						tmp_path_factory.mktemp('data'					) / 'dataset_with_dir.jsonl.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.join('main_dir'				,					os.path.basename(lowerCamelCase_					)					)					)
        f.write(lowerCamelCase_				,					arcname=os.path.join('main_dir'				,					os.path.basename(lowerCamelCase_					)					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Optional[int]:
    _lowercase			:				Tuple 						=						tmp_path_factory.mktemp('data'					) / 'dataset.jsonl.tar'
    with tarfile.TarFile(lowerCamelCase_				,					'w'					) as f:
        f.add(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
        f.add(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Any:
    _lowercase			:				str 						=						tmp_path_factory.mktemp('data'					) / 'dataset_nested.jsonl.tar'
    with tarfile.TarFile(lowerCamelCase_				,					'w'					) as f:
        f.add(lowerCamelCase_				,					arcname=os.path.join('nested'				,					os.path.basename(lowerCamelCase_					)					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Any:
    _lowercase			:				Optional[int] 						=						['0', '1', '2', '3']
    _lowercase			:				str 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.txt'					)
    with open(lowerCamelCase_				,					'w'					) as f:
        for item in data:
            f.write(item + '\n'					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Union[str, Any]:
    _lowercase			:				str 						=						['0', '1', '2', '3']
    _lowercase			:				List[Any] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset2.txt'					)
    with open(lowerCamelCase_				,					'w'					) as f:
        for item in data:
            f.write(item + '\n'					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		List[str]:
    _lowercase			:				List[Any] 						=						['0', '1', '2', '3']
    _lowercase			:				Optional[int] 						=						tmp_path_factory.mktemp('data'					) / 'dataset.abc'
    with open(lowerCamelCase_				,					'w'					) as f:
        for item in data:
            f.write(item + '\n'					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Any:
    _lowercase			:				Optional[Any] 						=						tmp_path_factory.mktemp('data'					) / 'dataset.text.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
        f.write(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Dict:
    _lowercase			:				List[Any] 						=						tmp_path_factory.mktemp('data'					) / 'dataset_with_dir.text.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.join('main_dir'				,					os.path.basename(lowerCamelCase_					)					)					)
        f.write(lowerCamelCase_				,					arcname=os.path.join('main_dir'				,					os.path.basename(lowerCamelCase_					)					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		str:
    _lowercase			:				Any 						=						tmp_path_factory.mktemp('data'					) / 'dataset.ext.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.basename('unsupported.ext'					)					)
        f.write(lowerCamelCase_				,					arcname=os.path.basename('unsupported_2.ext'					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		int:
    _lowercase			:				List[str] 						=						'\n'.join(['First', 'Second\u2029with Unicode new line', 'Third']					)
    _lowercase			:				Any 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset_with_unicode_new_lines.txt'					)
    with open(lowerCamelCase_				,					'w'				,					encoding='utf-8'					) as f:
        f.write(lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( )       ->		Dict:
    return os.path.join('tests'				,					'features'				,					'data'				,					'test_image_rgb.jpg'					)



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( )       ->		int:
    return os.path.join('tests'				,					'features'				,					'data'				,					'test_audio_44100.wav'					)



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		Any:
    _lowercase			:				Dict 						=						tmp_path_factory.mktemp('data'					) / 'dataset.img.zip'
    with zipfile.ZipFile(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					)					)
        f.write(lowerCamelCase_				,					arcname=os.path.basename(lowerCamelCase_					).replace('.jpg'				,					'2.jpg'					)					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Optional[Any]:
    _lowercase			:				str 						=						tmp_path_factory.mktemp('data_dir'					)

    (data_dir / "subdir").mkdir()
    with open(data_dir / 'subdir' / 'train.txt'				,					'w'					) as f:
        f.write('foo\n' * 10					)
    with open(data_dir / 'subdir' / 'test.txt'				,					'w'					) as f:
        f.write('bar\n' * 10					)
    # hidden file
    with open(data_dir / 'subdir' / '.test.txt'				,					'w'					) as f:
        f.write('bar\n' * 10					)

    # hidden directory
    (data_dir / ".subdir").mkdir()
    with open(data_dir / '.subdir' / 'train.txt'				,					'w'					) as f:
        f.write('foo\n' * 10					)
    with open(data_dir / '.subdir' / 'test.txt'				,					'w'					) as f:
        f.write('bar\n' * 10					)

    return data_dir


