


'''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  UpperCamelCase__(     unittest.TestCase ):




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

										"""simple docstring"""




										UpperCAmelCase         =			10




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

										"""simple docstring"""




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




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

										"""simple docstring"""




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




				def   a__(	self    :				List[Any]   )->  Tuple:

										"""simple docstring"""




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




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

										"""simple docstring"""




										UpperCAmelCase         =			'''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.'''
										UpperCAmelCase       ,       UpperCAmelCase         =			process_story(lowerCAmelCase   )
										self.assertEqual(lowerCAmelCase   ,					[]   )




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

										"""simple docstring"""




										UpperCAmelCase         =			''''''
										UpperCAmelCase       ,       UpperCAmelCase         =			process_story(lowerCAmelCase   )
										self.assertEqual(lowerCAmelCase   ,					[]   )
										self.assertEqual(lowerCAmelCase   ,					[]   )




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

										"""simple docstring"""




										UpperCAmelCase         =			(
										    '''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'''
										)
										UpperCAmelCase       ,       UpperCAmelCase         =			process_story(lowerCAmelCase   )

										UpperCAmelCase         =			[
										    '''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(lowerCAmelCase   ,					lowerCAmelCase   )

										UpperCAmelCase         =			['''It was the best of times.''']
										self.assertEqual(lowerCAmelCase   ,					lowerCAmelCase   )




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

										"""simple docstring"""




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




				def   a__(	self    :				Any   )->  Any:

										"""simple docstring"""




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




				def   a__(	self    :				Tuple   )->  Any:

										"""simple docstring"""




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





				def   a__(	self    :				Optional[int]   )->  str:

										"""simple docstring"""




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

										UpperCAmelCase         =			compute_token_type_ids(lowerCAmelCase   ,					lowerCAmelCase   )
										np.testing.assert_array_equal(lowerCAmelCase   ,					lowerCAmelCase   )









'''simple docstring'''



# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowercase    :    int			     =  {
    """configuration_xmod""": [
        """XMOD_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """XmodConfig""",
        """XmodOnnxConfig""",
    ],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowercase    :    str			     =  [
	    """XMOD_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """XmodForCausalLM""",
	    """XmodForMaskedLM""",
	    """XmodForMultipleChoice""",
	    """XmodForQuestionAnswering""",
	    """XmodForSequenceClassification""",
	    """XmodForTokenClassification""",
	    """XmodModel""",
	    """XmodPreTrainedModel""",
	]

if TYPE_CHECKING:
	from .configuration_xmod import XMOD_PRETRAINED_CONFIG_ARCHIVE_MAP, XmodConfig, XmodOnnxConfig

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_xmod import (
		    XMOD_PRETRAINED_MODEL_ARCHIVE_LIST,
		    XmodForCausalLM,
		    XmodForMaskedLM,
		    XmodForMultipleChoice,
		    XmodForQuestionAnswering,
		    XmodForSequenceClassification,
		    XmodForTokenClassification,
		    XmodModel,
		    XmodPreTrainedModel,
		)

else:
	import sys

	_lowercase    :    List[Any]			     =  _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





