




'''simple docstring'''


import unittest

import numpy as np
import torch

from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad

class     A					(	unittest.TestCase					):







       def      __lowerCAmelCase    (						self :						Tuple      )    ->							Optional[Any]:


              """simple docstring"""


              _a			  =       10







       def      __lowerCAmelCase    (						self :						int      )    ->							Dict:


              """simple docstring"""


              _a			  =       [1, 2, 3, 4]
              _a			  =       [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
              self.assertEqual(truncate_or_pad(__A							,    self.block_size							,    0      )							,    __A      )







       def      __lowerCAmelCase    (						self :						Dict      )    ->							Optional[int]:


              """simple docstring"""


              _a			  =       [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
              _a			  =       [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
              self.assertEqual(truncate_or_pad(__A							,    self.block_size							,    0      )							,    __A      )







       def      __lowerCAmelCase    (						self :						Optional[Any]      )    ->							Optional[int]:


              """simple docstring"""


              _a			  =       [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
              _a			  =       [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
              self.assertEqual(truncate_or_pad(__A							,    self.block_size							,    0      )							,    __A      )







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


              """simple docstring"""


              _a			  =       "It was the year of Our Lord one thousand seven hundred and\n        seventy-five.\n\nSpiritual revelations were conceded to England at that\n        favoured period, as at this."
              _a			  =       process_story(__A      )
              self.assertEqual(__A							,    []      )







       def      __lowerCAmelCase    (						self :						List[str]      )    ->							Optional[Any]:


              """simple docstring"""


              _a			  =       ""
              _a			  =       process_story(__A      )
              self.assertEqual(__A							,    []      )
              self.assertEqual(__A							,    []      )







       def      __lowerCAmelCase    (						self :						Dict      )    ->							int:


              """simple docstring"""


              _a			  =       (
                  "It was the year of Our Lord one thousand seven hundred and "
                  "seventy-five\n\nSpiritual revelations were conceded to England "
                  "at that favoured period, as at this.\n@highlight\n\nIt was the best of times"
              )
              _a			  =       process_story(__A      )

              _a			  =       [
                  "It was the year of Our Lord one thousand seven hundred and seventy-five.",
                  "Spiritual revelations were conceded to England at that favoured period, as at this.",
              ]
              self.assertEqual(__A							,    __A      )

              _a			  =       ["It was the best of times."]
              self.assertEqual(__A							,    __A      )







       def      __lowerCAmelCase    (						self :						Optional[Any]      )    ->							str:


              """simple docstring"""


              _a			  =       torch.tensor([1, 2, 3, 4]      )
              _a			  =       torch.tensor([1, 1, 1, 1]      )
              np.testing.assert_array_equal(build_mask(__A							,    0      ).numpy()							,    expected.numpy()      )







       def      __lowerCAmelCase    (						self :						List[str]      )    ->							Any:


              """simple docstring"""


              _a			  =       torch.tensor([1, 2, 3, 4, 23, 23, 23]      )
              _a			  =       torch.tensor([1, 1, 1, 1, 0, 0, 0]      )
              np.testing.assert_array_equal(build_mask(__A							,    23      ).numpy()							,    expected.numpy()      )







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


              """simple docstring"""


              _a			  =       torch.tensor([8, 2, 3, 4, 1, 1, 1]      )
              _a			  =       torch.tensor([1, 1, 1, 1, 0, 0, 0]      )
              np.testing.assert_array_equal(build_mask(__A							,    1      ).numpy()							,    expected.numpy()      )







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


              """simple docstring"""


              _a			  =       1_01
              _a			  =       torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 1_01, 5, 6], [1, 1_01, 3, 4, 1_01, 6]]      )
              _a			  =       torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]      )

              _a			  =       compute_token_type_ids(__A							,    __A      )
              np.testing.assert_array_equal(__A							,    __A      )







'''simple docstring'''


import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


_snake_case   :   str     							=	'\nHugging 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.\n\nIn March 2021, Hugging Face raised $40 million in a Series B funding round.[3]\n\nOn 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]\n'

class     A					(	unittest.TestCase  ,_a					):







							def      __lowerCAmelCase    (						self :						Any      )    ->							Dict:


														"""simple docstring"""


														_a			  =       load_tool('''text-question-answering'''      )
														self.tool.setup()
														_a			  =       load_tool('''text-question-answering'''							,    remote=lowerCAmelCase_      )







							def      __lowerCAmelCase    (						self :						List[Any]      )    ->							Optional[int]:


														"""simple docstring"""


														_a			  =       self.tool(lowerCAmelCase_							,    '''What did Hugging Face do in April 2021?'''      )
														self.assertEqual(lowerCAmelCase_							,    '''launched the BigScience Research Workshop'''      )







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


														"""simple docstring"""


														_a			  =       self.remote_tool(lowerCAmelCase_							,    '''What did Hugging Face do in April 2021?'''      )
														self.assertEqual(lowerCAmelCase_							,    '''launched the BigScience Research Workshop'''      )







							def      __lowerCAmelCase    (						self :						List[Any]      )    ->							List[str]:


														"""simple docstring"""


														_a			  =       self.tool(text=lowerCAmelCase_							,    question='''What did Hugging Face do in April 2021?'''      )
														self.assertEqual(lowerCAmelCase_							,    '''launched the BigScience Research Workshop'''      )







							def      __lowerCAmelCase    (						self :						int      )    ->							List[Any]:


														"""simple docstring"""


														_a			  =       self.remote_tool(text=lowerCAmelCase_							,    question='''What did Hugging Face do in April 2021?'''      )
														self.assertEqual(lowerCAmelCase_							,    '''launched the BigScience Research Workshop'''      )

