


'''simple docstring'''




import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


__lowercase	:   str   		=					"""
Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers.[2] After open-sourcing the model behind the chatbot, the company pivoted to focus on being a platform for machine learning.

In March 2021, Hugging Face raised $40 million in a Series B funding round.[3]

On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model.[4] In 2022, the workshop concluded with the announcement of BLOOM, a multilingual large language model with 176 billion parameters.[5]
"""





class _snake_case (			unittest.TestCase     , a__ ):
							"""simple docstring"""





							def 		__SCREAMING_SNAKE_CASE( self						)  ->Any:



											"""simple docstring"""







											__lowerCamelCase		:   int           =       load_tool("summarization"						)
											self.tool.setup()
											__lowerCamelCase		:   List[Any]           =       load_tool("summarization"      ,					remote=__A						)







							def 		__SCREAMING_SNAKE_CASE( self						)  ->Any:



											"""simple docstring"""







											__lowerCamelCase		:   int           =       self.tool(__A						)
											self.assertEqual(
											    __A      ,					"Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM."      ,					)







							def 		__SCREAMING_SNAKE_CASE( self						)  ->Dict:



											"""simple docstring"""







											__lowerCamelCase		:   Dict           =       self.remote_tool(__A						)
											self.assertEqual(
											    __A      ,					"Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM."      ,					)







							def 		__SCREAMING_SNAKE_CASE( self						)  ->Optional[int]:



											"""simple docstring"""







											__lowerCamelCase		:   int           =       self.tool(text=__A						)
											self.assertEqual(
											    __A      ,					"Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM."      ,					)







							def 		__SCREAMING_SNAKE_CASE( self						)  ->str:



											"""simple docstring"""







											__lowerCamelCase		:   List[str]           =       self.remote_tool(text=__A						)
											self.assertEqual(
											    __A      ,					"Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM."      ,					)









'''simple docstring'''




#
# Sort large text files in a minimum amount of memory
#
import argparse
import os





class _snake_case :
							"""simple docstring"""





							__a				       =  '''block_{0}.dat'''







							def __init__( self      ,					__A						)  ->int:



											"""simple docstring"""







											__lowerCamelCase		:   Dict           =       filename
											__lowerCamelCase		:   Union[str, Any]           =       []







							def 		__SCREAMING_SNAKE_CASE( self      ,					__A      ,					__A						)  ->int:



											"""simple docstring"""







											__lowerCamelCase		:   Optional[int]           =       self.BLOCK_FILENAME_FORMAT.format(__A						)
											with open(__A      ,					"w"						) as file:
															file.write(__A						)
											self.block_filenames.append(__A						)







							def 		__SCREAMING_SNAKE_CASE( self						)  ->int:



											"""simple docstring"""







											return self.block_filenames







							def 		__SCREAMING_SNAKE_CASE( self      ,					__A      ,					__A=None						)  ->Dict:



											"""simple docstring"""







											__lowerCamelCase		:   Optional[int]           =       0
											with open(self.filename						) as file:
															while True:
																			__lowerCamelCase		:   Union[str, Any]           =       file.readlines(__A						)

																			if lines == []:
																							break

																			if sort_key is None:
																							lines.sort()
																			else:
																							lines.sort(key=__A						)

																			self.write_block("".join(__A						)      ,					__A						)
																			i += 1







							def 		__SCREAMING_SNAKE_CASE( self						)  ->List[Any]:



											"""simple docstring"""







											map(os.remove      ,					self.block_filenames						)





class _snake_case :
							"""simple docstring"""





							def 		__SCREAMING_SNAKE_CASE( self      ,					__A						)  ->Optional[int]:



											"""simple docstring"""







											__lowerCamelCase		:   Union[str, Any]           =       -1
											__lowerCamelCase		:   Optional[Any]           =       None

											for i in range(len(__A						)						):
															if min_str is None or choices[i] < min_str:
																			__lowerCamelCase		:   Tuple           =       i

											return min_index





class _snake_case :
							"""simple docstring"""





							def __init__( self      ,					__A						)  ->List[Any]:



											"""simple docstring"""







											__lowerCamelCase		:   Tuple           =       files
											__lowerCamelCase		:   Tuple           =       set()
											__lowerCamelCase		:   Optional[Any]           =       len(__A						)
											__lowerCamelCase		:   List[str]           =       {i: None for i in range(self.num_buffers						)}







							def 		__SCREAMING_SNAKE_CASE( self						)  ->Any:



											"""simple docstring"""







											return {
											    i: self.buffers[i] for i in range(self.num_buffers						) if i not in self.empty
											}







							def 		__SCREAMING_SNAKE_CASE( self						)  ->Dict:



											"""simple docstring"""







											for i in range(self.num_buffers						):
															if self.buffers[i] is None and i not in self.empty:
																			__lowerCamelCase		:   Tuple           =       self.files[i].readline()

																			if self.buffers[i] == "":
																							self.empty.add(__A						)
																							self.files[i].close()

											if len(self.empty						) == self.num_buffers:
															return False

											return True







							def 		__SCREAMING_SNAKE_CASE( self      ,					__A						)  ->Any:



											"""simple docstring"""







											__lowerCamelCase		:   Tuple           =       self.buffers[index]
											__lowerCamelCase		:   List[Any]           =       None

											return value





class _snake_case :
							"""simple docstring"""





							def __init__( self      ,					__A						)  ->List[str]:



											"""simple docstring"""







											__lowerCamelCase		:   List[Any]           =       merge_strategy







							def 		__SCREAMING_SNAKE_CASE( self      ,					__A      ,					__A      ,					__A						)  ->Optional[int]:



											"""simple docstring"""







											__lowerCamelCase		:   List[str]           =       FilesArray(self.get_file_handles(__A      ,					__A						)						)
											with open(__A      ,					"w"      ,					__A						) as outfile:
															while buffers.refresh():
																			__lowerCamelCase		:   Optional[Any]           =       self.merge_strategy.select(buffers.get_dict()						)
																			outfile.write(buffers.unshift(__A						)						)







							def 		__SCREAMING_SNAKE_CASE( self      ,					__A      ,					__A						)  ->str:



											"""simple docstring"""







											__lowerCamelCase		:   Union[str, Any]           =       {}

											for i in range(len(__A						)						):
															__lowerCamelCase		:   Tuple           =       open(filenames[i]      ,					"r"      ,					__A						)  # noqa: UP015

											return files





class _snake_case :
							"""simple docstring"""





							def __init__( self      ,					__A						)  ->str:



											"""simple docstring"""







											__lowerCamelCase		:   Tuple           =       block_size







							def 		__SCREAMING_SNAKE_CASE( self      ,					__A      ,					__A=None						)  ->List[str]:



											"""simple docstring"""







											__lowerCamelCase		:   Optional[int]           =       self.get_number_blocks(__A      ,					self.block_size						)
											__lowerCamelCase		:   Optional[int]           =       FileSplitter(__A						)
											splitter.split(self.block_size      ,					__A						)

											__lowerCamelCase		:   List[str]           =       FileMerger(NWayMerge()						)
											__lowerCamelCase		:   str           =       self.block_size / (num_blocks + 1)
											merger.merge(splitter.get_block_filenames()      ,					filename + ".out"      ,					__A						)

											splitter.cleanup()







							def 		__SCREAMING_SNAKE_CASE( self      ,					__A      ,					__A						)  ->List[str]:



											"""simple docstring"""







											return (os.stat(__A						).st_size / block_size) + 1





def 				a_							(    lowercase     )      ->List[Any]:






				'''simple docstring'''

				if string[-1].lower() == "k":
								return int(string[:-1]     ) * 1024
				elif string[-1].lower() == "m":
								return int(string[:-1]     ) * 1024 * 1024
				elif string[-1].lower() == "g":
								return int(string[:-1]     ) * 1024 * 1024 * 1024
				else:
								return int(lowercase     )





def 				a_							(    )      ->Optional[Any]:






				'''simple docstring'''

				__lowerCamelCase		:   List[str]           =       argparse.ArgumentParser()
				parser.add_argument(
				    "-m"				,    "--mem"				,    help="amount of memory to use for sorting"				,    default="100M"     )
				parser.add_argument(
				    "filename"				,    metavar="<filename>"				,    nargs=1				,    help="name of file to sort"     )
				__lowerCamelCase		:   List[str]           =       parser.parse_args()

				__lowerCamelCase		:   Tuple           =       ExternalSort(parse_memory(args.mem     )     )
				sorter.sort(args.filename[0]     )


if __name__ == "__main__":
				main()





