


'''simple docstring'''






from __future__ import annotations

import unittest

from transformers import AutoTokenizer, PegasusConfig, is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
						import tensorflow as tf

						from transformers import TFAutoModelForSeqaSeqLM, TFPegasusForConditionalGeneration, TFPegasusModel






@require_tf
class   SCREAMING_SNAKE_CASE_						:
			__a       :   List[Any]       =	PegasusConfig
			__a       :   Tuple       =	{}
			__a       :   str       =	'gelu'




			def __init__(   self       ,   lowercase       ,   lowercase=1_3       ,   lowercase=7       ,   lowercase=True       ,   lowercase=False       ,   lowercase=9_9       ,   lowercase=3_2       ,   lowercase=2       ,   lowercase=4       ,   lowercase=3_7       ,   lowercase=0.1       ,   lowercase=0.1       ,   lowercase=4_0       ,   lowercase=2       ,   lowercase=1       ,   lowercase=0       ,   )      ->    List[str]:


								'''simple docstring'''






								__SCREAMING_SNAKE_CASE       :				int       =			parent
								__SCREAMING_SNAKE_CASE       :				Tuple       =			batch_size
								__SCREAMING_SNAKE_CASE       :				Any       =			seq_length
								__SCREAMING_SNAKE_CASE       :				Optional[Any]       =			is_training
								__SCREAMING_SNAKE_CASE       :				List[Any]       =			use_labels
								__SCREAMING_SNAKE_CASE       :				Tuple       =			vocab_size
								__SCREAMING_SNAKE_CASE       :				Optional[Any]       =			hidden_size
								__SCREAMING_SNAKE_CASE       :				str       =			num_hidden_layers
								__SCREAMING_SNAKE_CASE       :				Dict       =			num_attention_heads
								__SCREAMING_SNAKE_CASE       :				Any       =			intermediate_size

								__SCREAMING_SNAKE_CASE       :				List[Any]       =			hidden_dropout_prob
								__SCREAMING_SNAKE_CASE       :				Any       =			attention_probs_dropout_prob
								__SCREAMING_SNAKE_CASE       :				List[str]       =			max_position_embeddings
								__SCREAMING_SNAKE_CASE       :				Any       =			eos_token_id
								__SCREAMING_SNAKE_CASE       :				Any       =			pad_token_id
								__SCREAMING_SNAKE_CASE       :				List[Any]       =			bos_token_id




			def       _snake_case (   self							)      ->    Optional[Any]:


								'''simple docstring'''






								__SCREAMING_SNAKE_CASE       :				Any       =			ids_tensor([self.batch_size, self.seq_length - 1]       ,   self.vocab_size							)
								__SCREAMING_SNAKE_CASE       :				Union[str, Any]       =			tf.expand_dims(tf.constant([self.eos_token_id] * self.batch_size							)       ,   1							)
								__SCREAMING_SNAKE_CASE       :				Optional[Any]       =			tf.concat([input_ids, eos_tensor]       ,   axis=1							)

								__SCREAMING_SNAKE_CASE       :				Tuple       =			ids_tensor([self.batch_size, self.seq_length]       ,   self.vocab_size							)

								__SCREAMING_SNAKE_CASE       :				Any       =			self.config_cls(
								    vocab_size=self.vocab_size       ,   d_model=self.hidden_size       ,   encoder_layers=self.num_hidden_layers       ,   decoder_layers=self.num_hidden_layers       ,   encoder_attention_heads=self.num_attention_heads       ,   decoder_attention_heads=self.num_attention_heads       ,   encoder_ffn_dim=self.intermediate_size       ,   decoder_ffn_dim=self.intermediate_size       ,   dropout=self.hidden_dropout_prob       ,   attention_dropout=self.attention_probs_dropout_prob       ,   max_position_embeddings=self.max_position_embeddings       ,   eos_token_ids=[2]       ,   bos_token_id=self.bos_token_id       ,   pad_token_id=self.pad_token_id       ,   decoder_start_token_id=self.pad_token_id       ,   **self.config_updates       ,   )
								__SCREAMING_SNAKE_CASE       :				Tuple       =			prepare_pegasus_inputs_dict(_UpperCAmelCase       ,   _UpperCAmelCase       ,   _UpperCAmelCase							)
								return config, inputs_dict




			def       _snake_case (   self       ,   lowercase       ,   lowercase							)      ->    int:


								'''simple docstring'''






								__SCREAMING_SNAKE_CASE       :				Dict       =			TFPegasusModel(config=_UpperCAmelCase							).get_decoder()
								__SCREAMING_SNAKE_CASE       :				List[Any]       =			inputs_dict['input_ids']

								__SCREAMING_SNAKE_CASE       :				int       =			input_ids[:1, :]
								__SCREAMING_SNAKE_CASE       :				Any       =			inputs_dict['attention_mask'][:1, :]
								__SCREAMING_SNAKE_CASE       :				Optional[int]       =			inputs_dict['head_mask']
								__SCREAMING_SNAKE_CASE       :				Tuple       =			1

								# first forward pass
								__SCREAMING_SNAKE_CASE       :				Any       =			model(_UpperCAmelCase       ,   attention_mask=_UpperCAmelCase       ,   head_mask=_UpperCAmelCase       ,   use_cache=_UpperCAmelCase							)

								__SCREAMING_SNAKE_CASE       :				Union[str, Any]       =			outputs.to_tuple()

								# create hypothetical next token and extent to next_input_ids
								__SCREAMING_SNAKE_CASE       :				List[Any]       =			ids_tensor((self.batch_size, 3)       ,   config.vocab_size							)
								__SCREAMING_SNAKE_CASE       :				int       =			tf.cast(ids_tensor((self.batch_size, 3)       ,   2							)       ,   tf.inta							)

								# append to next input_ids and
								__SCREAMING_SNAKE_CASE       :				str       =			tf.concat([input_ids, next_tokens]       ,   axis=-1							)
								__SCREAMING_SNAKE_CASE       :				Union[str, Any]       =			tf.concat([attention_mask, next_attn_mask]       ,   axis=-1							)

								__SCREAMING_SNAKE_CASE       :				Tuple       =			model(_UpperCAmelCase       ,   attention_mask=_UpperCAmelCase							)[0]
								__SCREAMING_SNAKE_CASE       :				Any       =			model(_UpperCAmelCase       ,   attention_mask=_UpperCAmelCase       ,   past_key_values=_UpperCAmelCase							)[0]

								self.parent.assertEqual(next_tokens.shape[1]       ,   output_from_past.shape[1]							)

								# select random slice
								__SCREAMING_SNAKE_CASE       :				List[str]       =			int(ids_tensor((1,)       ,   output_from_past.shape[-1]							)							)
								__SCREAMING_SNAKE_CASE       :				Dict       =			output_from_no_past[:, -3:, random_slice_idx]
								__SCREAMING_SNAKE_CASE       :				Dict       =			output_from_past[:, :, random_slice_idx]

								# test that outputs are equal for slice
								tf.debugging.assert_near(_UpperCAmelCase       ,   _UpperCAmelCase       ,   rtol=1e-3							)




def A_       (					__SCREAMING_SNAKE_CASE			:       Any						, __SCREAMING_SNAKE_CASE			:       Union[str, Any]						, __SCREAMING_SNAKE_CASE			:       List[str]						, __SCREAMING_SNAKE_CASE			:       Union[str, Any]=None						, __SCREAMING_SNAKE_CASE			:       List[Any]=None						, __SCREAMING_SNAKE_CASE			:       str=None						, __SCREAMING_SNAKE_CASE			:       Optional[int]=None						, __SCREAMING_SNAKE_CASE			:       str=None						, )  ->	Optional[Any]:
					if attention_mask is None:
										__SCREAMING_SNAKE_CASE       :				Any       =			tf.cast(tf.math.not_equal(lowerCAmelCase_						, config.pad_token_id							)						, tf.inta							)
					if decoder_attention_mask is None:
										__SCREAMING_SNAKE_CASE       :				Dict       =			tf.concat(
										    [
										        tf.ones(decoder_input_ids[:, :1].shape						, dtype=tf.inta							),
										        tf.cast(tf.math.not_equal(decoder_input_ids[:, 1:]						, config.pad_token_id							)						, tf.inta							),
										    ]						, axis=-1						, )
					if head_mask is None:
										__SCREAMING_SNAKE_CASE       :				Any       =			tf.ones((config.encoder_layers, config.encoder_attention_heads)							)
					if decoder_head_mask is None:
										__SCREAMING_SNAKE_CASE       :				Optional[Any]       =			tf.ones((config.decoder_layers, config.decoder_attention_heads)							)
					if cross_attn_head_mask is None:
										__SCREAMING_SNAKE_CASE       :				Optional[Any]       =			tf.ones((config.decoder_layers, config.decoder_attention_heads)							)
					return {
					    "input_ids": input_ids,
					    "decoder_input_ids": decoder_input_ids,
					    "attention_mask": attention_mask,
					    "decoder_attention_mask": decoder_attention_mask,
					    "head_mask": head_mask,
					    "decoder_head_mask": decoder_head_mask,
					    "cross_attn_head_mask": cross_attn_head_mask,
					}






@require_tf
class   SCREAMING_SNAKE_CASE_						(			_UpperCamelCase       ,       _UpperCamelCase       ,       unittest.TestCase		):
			__a       :   List[Any]       =	(TFPegasusForConditionalGeneration, TFPegasusModel) if is_tf_available() else ()
			__a       :   int       =	(TFPegasusForConditionalGeneration,) if is_tf_available() else ()
			__a       :   Union[str, Any]       =	(
			    {
			        'conversational': TFPegasusForConditionalGeneration,
			        'feature-extraction': TFPegasusModel,
			        'summarization': TFPegasusForConditionalGeneration,
			        'text2text-generation': TFPegasusForConditionalGeneration,
			        'translation': TFPegasusForConditionalGeneration,
			    }
			    if is_tf_available()
			    else {}
			)
			__a       :   Dict       =	True
			__a       :   Tuple       =	False
			__a       :   Tuple       =	False




			def       _snake_case (   self							)      ->    Tuple:


								'''simple docstring'''






								__SCREAMING_SNAKE_CASE       :				Union[str, Any]       =			TFPegasusModelTester(self							)
								__SCREAMING_SNAKE_CASE       :				int       =			ConfigTester(self       ,   config_class=_UpperCAmelCase							)




			def       _snake_case (   self							)      ->    Union[str, Any]:


								'''simple docstring'''






								self.config_tester.run_common_tests()




			def       _snake_case (   self							)      ->    Tuple:


								'''simple docstring'''






								__SCREAMING_SNAKE_CASE       :				Dict       =			self.model_tester.prepare_config_and_inputs_for_common()
								self.model_tester.check_decoder_model_past_large_inputs(*_UpperCAmelCase							)






@require_sentencepiece
@require_tokenizers
@require_tf
class   SCREAMING_SNAKE_CASE_						(			unittest.TestCase		):
			__a       :   Optional[Any]       =	[
			    ' PG&E stated it scheduled the blackouts in response to forecasts for high winds amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow.',
			    ' The London trio are up for best UK act and best album, as well as getting two nominations in the best song category."We got told like this morning \'Oh I think you\'re nominated\'", said Dappy."And I was like \'Oh yeah, which one?\' And now we\'ve got nominated for four awards. I mean, wow!"Bandmate Fazer added: "We thought it\'s best of us to come down and mingle with everyone and say hello to the cameras. And now we find we\'ve got four nominations."The band have two shots at the best song prize, getting the nod for their Tynchy Stryder collaboration Number One, and single Strong Again.Their album Uncle B will also go up against records by the likes of Beyonce and Kanye West.N-Dubz picked up the best newcomer Mobo in 2007, but female member Tulisa said they wouldn\'t be too disappointed if they didn\'t win this time around."At the end of the day we\'re grateful to be where we are in our careers."If it don\'t happen then it don\'t happen - live to fight another day and keep on making albums and hits for the fans."Dappy also revealed they could be performing live several times on the night.The group will be doing Number One and also a possible rendition of the War Child single, I Got Soul.The charity song is a  re-working of The Killers\' All These Things That I\'ve Done and is set to feature artists like Chipmunk, Ironik and Pixie Lott.This year\'s Mobos will be held outside of London for the first time, in Glasgow on 30 September.N-Dubz said they were looking forward to performing for their Scottish fans and boasted about their recent shows north of the border."We just done Edinburgh the other day," said Dappy."We smashed up an N-Dubz show over there. We done Aberdeen about three or four months ago - we smashed up that show over there! Everywhere we go we smash it up!" ',
			]
			__a       :   str       =	[
			    'California\'s largest electricity provider has cut power to hundreds of thousands of customers in an effort to'
			    ' reduce the risk of wildfires.',
			    'N-Dubz have revealed they\'re "grateful" to have been nominated for four Mobo Awards.',
			]  # differs slightly from pytorch, likely due to numerical differences in linear layers
			__a       :   Union[str, Any]       =	'google/pegasus-xsum'




			@cached_property
			def       _snake_case (   self							)      ->    Optional[int]:


								'''simple docstring'''






								return AutoTokenizer.from_pretrained(self.model_name							)




			@cached_property
			def       _snake_case (   self							)      ->    List[Any]:


								'''simple docstring'''






								__SCREAMING_SNAKE_CASE       :				Dict       =			TFAutoModelForSeqaSeqLM.from_pretrained(self.model_name							)
								return model




			def       _snake_case (   self       ,   **lowercase							)      ->    str:


								'''simple docstring'''






								__SCREAMING_SNAKE_CASE       :				Dict       =			self.translate_src_text(**_UpperCAmelCase							)
								assert self.expected_text == generated_words




			def       _snake_case (   self       ,   **lowercase							)      ->    Tuple:


								'''simple docstring'''






								__SCREAMING_SNAKE_CASE       :				List[str]       =			self.tokenizer(self.src_text       ,   **_UpperCAmelCase       ,   padding=_UpperCAmelCase       ,   return_tensors='''tf'''							)
								__SCREAMING_SNAKE_CASE       :				Optional[Any]       =			self.model.generate(
								    model_inputs.input_ids       ,   attention_mask=model_inputs.attention_mask       ,   num_beams=2       ,   use_cache=_UpperCAmelCase       ,   )
								__SCREAMING_SNAKE_CASE       :				List[Any]       =			self.tokenizer.batch_decode(generated_ids.numpy()       ,   skip_special_tokens=_UpperCAmelCase							)
								return generated_words




			@slow
			def       _snake_case (   self							)      ->    Tuple:


								'''simple docstring'''






								self._assert_generated_batch_equal_expected()







'''simple docstring'''

# Lint as: python3
import os
import re
import urllib.parse
from pathlib import Path
from typing import Callable, List, Optional, Union
from zipfile import ZipFile

from ..utils.file_utils import cached_path, hf_github_url
from ..utils.logging import get_logger
from ..utils.version import Version


__lowerCAmelCase		     =  get_logger(__name__)

class       __magic_name__		:
							lowerCAmelCase			:       Optional[Any]  							=   'dummy_data'
							lowerCAmelCase			:       List[str]  							=   'datasets'
							lowerCAmelCase			:       str  							=   False







							def __init__(				self   :			Tuple      ,_UpperCAmelCase   :			str      ,_UpperCAmelCase   :			str      ,_UpperCAmelCase   :			Union[Version, str]      ,_UpperCAmelCase   :			Optional[str] = None      ,_UpperCAmelCase   :			bool = False      ,_UpperCAmelCase   :			bool = True      ,_UpperCAmelCase   :			Optional[List[Callable]] = None      ,):
									_a	: int								=				0
									_a	: str								=				dataset_name
									_a	: Optional[int]								=				cache_dir
									_a	: int								=				use_local_dummy_data
									_a	: Optional[int]								=				config
									# download_callbacks take a single url as input
									_a	: List[Callable]								=				download_callbacks or []
									# if False, it doesn't load existing files and it returns the paths of the dummy files relative
									# to the dummy_data zip file root
									_a	: str								=				load_existing_dummy_data

									# TODO(PVP, QL) might need to make this more general
									_a	: Optional[int]								=				str(_UpperCAmelCase						)
									# to be downloaded
									_a	: Union[str, Any]								=				None
									_a	: Dict								=				None







							@property
							def 				__lowercase     (				self   :			Any						):
									if self._dummy_file is None:
											_a	: Dict								=				self.download_dummy_data()
									return self._dummy_file







							@property
							def 				__lowercase     (				self   :			Optional[int]						):
									if self.config is not None:
											# structure is dummy / config_name / version_name
											return os.path.join('dummy'      ,self.config.name      ,self.version_name						)
									# structure is dummy / version_name
									return os.path.join('dummy'      ,self.version_name						)







							@property
							def 				__lowercase     (				self   :			Any						):
									return os.path.join(self.dummy_data_folder      ,'dummy_data.zip'						)







							def 				__lowercase     (				self   :			List[str]						):
									_a	: Dict								=				(
									    self.local_path_to_dummy_data if self.use_local_dummy_data is True else self.github_path_to_dummy_data
									)

									_a	: Dict								=				cached_path(
									    _UpperCAmelCase      ,cache_dir=self.cache_dir      ,extract_compressed_file=_UpperCAmelCase      ,force_extract=_UpperCAmelCase						)

									return os.path.join(_UpperCAmelCase      ,self.dummy_file_name						)







							@property
							def 				__lowercase     (				self   :			List[str]						):
									return os.path.join(self.datasets_scripts_dir      ,self.dataset_name      ,self.dummy_zip_file						)







							@property
							def 				__lowercase     (				self   :			Optional[Any]						):
									if self._bucket_url is None:
											_a	: Any								=				hf_github_url(self.dataset_name      ,self.dummy_zip_file.replace(os.sep      ,'/'						)						)
									return self._bucket_url







							@property
							def 				__lowercase     (				self   :			int						):
									# return full path if its a dir
									if os.path.isdir(self.dummy_file						):
											return self.dummy_file
									# else cut off path to file -> example `xsum`.
									return "/".join(self.dummy_file.replace(os.sep      ,'/'						).split('/'						)[:-1]						)







							def 				__lowercase     (				self   :			Dict      ,_UpperCAmelCase   :			str      ,*_UpperCAmelCase   :			int						):
									if self.load_existing_dummy_data:
											# dummy data is downloaded and tested
											_a	: List[Any]								=				self.dummy_file
									else:
											# dummy data cannot be downloaded and only the path to dummy file is returned
											_a	: str								=				self.dummy_file_name

									# special case when data_url is a dict
									if isinstance(_UpperCAmelCase      ,_UpperCAmelCase						):
											return self.create_dummy_data_dict(_UpperCAmelCase      ,_UpperCAmelCase						)
									elif isinstance(_UpperCAmelCase      ,(list, tuple)						):
											return self.create_dummy_data_list(_UpperCAmelCase      ,_UpperCAmelCase						)
									else:
											return self.create_dummy_data_single(_UpperCAmelCase      ,_UpperCAmelCase						)







							def 				__lowercase     (				self   :			List[str]      ,_UpperCAmelCase   :			Optional[int]      ,*_UpperCAmelCase   :			Optional[int]						):
									return self.download_and_extract(_UpperCAmelCase						)







							def 				__lowercase     (				self   :			Tuple      ,_UpperCAmelCase   :			List[Any]      ,_UpperCAmelCase   :			Optional[Any]						):
									return self.download_and_extract(_UpperCAmelCase						)







							def 				__lowercase     (				self   :			List[str]      ,_UpperCAmelCase   :			List[str]      ,*_UpperCAmelCase   :			int      ,**_UpperCAmelCase   :			Dict						):
									return path







							def 				__lowercase     (				self   :			Optional[Any]						):
									return {}







							def 				__lowercase     (				self   :			Optional[Any]      ,_UpperCAmelCase   :			List[Any]      ,_UpperCAmelCase   :			str						):
									_a	: int								=				{}
									for key, single_urls in data_url.items():
											for download_callback in self.download_callbacks:
													if isinstance(_UpperCAmelCase      ,_UpperCAmelCase						):
															for single_url in single_urls:
																	download_callback(_UpperCAmelCase						)
													else:
															_a	: Union[str, Any]								=				single_urls
															download_callback(_UpperCAmelCase						)
            # we force the name of each key to be the last file / folder name of the url path
            # if the url has arguments, we need to encode them with urllib.parse.quote_plus
											if isinstance(_UpperCAmelCase      ,_UpperCAmelCase						):
													_a	: Optional[int]								=				[os.path.join(_UpperCAmelCase      ,urllib.parse.quote_plus(Path(_UpperCAmelCase						).name						)						) for x in single_urls]
											else:
													_a	: Tuple								=				single_urls
													_a	: Optional[Any]								=				os.path.join(_UpperCAmelCase      ,urllib.parse.quote_plus(Path(_UpperCAmelCase						).name						)						)
											_a	: Union[str, Any]								=				value

									# make sure that values are unique
									if all(isinstance(_UpperCAmelCase      ,_UpperCAmelCase						) for i in dummy_data_dict.values()						) and len(set(dummy_data_dict.values()						)						) < len(
									    dummy_data_dict.values()						):
											# append key to value to make its name unique
											_a	: Dict								=				{key: value + key for key, value in dummy_data_dict.items()}

									return dummy_data_dict







							def 				__lowercase     (				self   :			List[Any]      ,_UpperCAmelCase   :			List[str]      ,_UpperCAmelCase   :			List[str]						):
									_a	: str								=				[]
									# trick: if there are many shards named like `data.txt-000001-of-00300`, only use the first one
									_a	: Tuple								=				all(bool(re.findall('[0-9]{3,}-of-[0-9]{3,}'      ,_UpperCAmelCase						)						) for url in data_url						)
									_a	: str								=				all(
									    url.startswith('https://ftp.ncbi.nlm.nih.gov/pubmed/baseline/pubmed'						) for url in data_url						)
									if data_url and (is_tf_records or is_pubmed_records):
											_a	: str								=				[data_url[0]] * len(_UpperCAmelCase						)
									for single_url in data_url:
											for download_callback in self.download_callbacks:
													download_callback(_UpperCAmelCase						)
											# we force the name of each key to be the last file / folder name of the url path
											# if the url has arguments, we need to encode them with urllib.parse.quote_plus
											_a	: List[Any]								=				os.path.join(_UpperCAmelCase      ,urllib.parse.quote_plus(single_url.split('/'						)[-1]						)						)
											dummy_data_list.append(_UpperCAmelCase						)
									return dummy_data_list







							def 				__lowercase     (				self   :			List[Any]      ,_UpperCAmelCase   :			Union[str, Any]      ,_UpperCAmelCase   :			List[str]						):
									for download_callback in self.download_callbacks:
											download_callback(_UpperCAmelCase						)
									# we force the name of each key to be the last file / folder name of the url path
									# if the url has arguments, we need to encode them with urllib.parse.quote_plus
									_a	: List[Any]								=				os.path.join(_UpperCAmelCase      ,urllib.parse.quote_plus(data_url.split('/'						)[-1]						)						)
									if os.path.exists(_UpperCAmelCase						) or not self.load_existing_dummy_data:
											return value
									else:
											# Backward compatibility, maybe deprecate at one point.
											# For many datasets with single url calls to dl_manager.download_and_extract,
											# the dummy_data.zip file is actually the zipped downloaded file
											# while now we expected the dummy_data.zip file to be a directory containing
											# the downloaded file.
											return path_to_dummy_data







							def 				__lowercase     (				self   :			Tuple						):
									pass







							def 				__lowercase     (				self   :			Optional[int]						):
									pass







							def 				__lowercase     (				self   :			List[str]      ,_UpperCAmelCase   :			Dict						):
									def _iter_archive_members(_UpperCAmelCase   :			List[Any]						):
											# this preserves the order of the members inside the ZIP archive
											_a	: int								=				Path(self.dummy_file						).parent
											_a	: List[str]								=				path.relative_to(_UpperCAmelCase						)
											with ZipFile(self.local_path_to_dummy_data						) as zip_file:
													_a	: List[Any]								=				zip_file.namelist()
											for member in members:
													if member.startswith(relative_path.as_posix()						):
															yield dummy_parent_path.joinpath(_UpperCAmelCase						)

									_a	: Dict								=				Path(_UpperCAmelCase						)
									_a	: Dict								=				_iter_archive_members(_UpperCAmelCase						) if self.use_local_dummy_data else path.rglob('*'						)
									for file_path in file_paths:
											if file_path.is_file() and not file_path.name.startswith(('.', '__')						):
													yield file_path.relative_to(_UpperCAmelCase						).as_posix(), file_path.open('rb'						)







							def 				__lowercase     (				self   :			Any      ,_UpperCAmelCase   :			Union[str, Any]						):
									if not isinstance(_UpperCAmelCase      ,_UpperCAmelCase						):
											_a	: str								=				[paths]
									for path in paths:
											if os.path.isfile(_UpperCAmelCase						):
													if os.path.basename(_UpperCAmelCase						).startswith(('.', '__')						):
															return
													yield path
											else:
													for dirpath, dirnames, filenames in os.walk(_UpperCAmelCase						):
															if os.path.basename(_UpperCAmelCase						).startswith(('.', '__')						):
																	continue
															dirnames.sort()
															for filename in sorted(_UpperCAmelCase						):
																	if filename.startswith(('.', '__')						):
																			continue
																	yield os.path.join(_UpperCAmelCase      ,_UpperCAmelCase						)




