


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

		"""simple docstring"""

		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :Any												= 10




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :Dict												= [1, 2, 3, 4]
							UpperCamelCase__   :Tuple												= [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
							self.assertEqual(truncate_or_pad(UpperCamelCase_    ,   self.block_size    ,   0							)    ,   UpperCamelCase_							)




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :List[str]												= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
							UpperCamelCase__   :Any												= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
							self.assertEqual(truncate_or_pad(UpperCamelCase_    ,   self.block_size    ,   0							)    ,   UpperCamelCase_							)




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :Any												= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
							UpperCamelCase__   :Optional[Any]												= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
							self.assertEqual(truncate_or_pad(UpperCamelCase_    ,   self.block_size    ,   0							)    ,   UpperCamelCase_							)




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :List[Any]												= '''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__   :int												= process_story(UpperCamelCase_							)
							self.assertEqual(UpperCamelCase_    ,   []							)




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :Tuple												= ''''''
							UpperCamelCase__					,				UpperCamelCase__   :List[str]												= process_story(UpperCamelCase_							)
							self.assertEqual(UpperCamelCase_    ,   []							)
							self.assertEqual(UpperCamelCase_    ,   []							)




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :Tuple												= (
							    '''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__   :Tuple												= process_story(UpperCamelCase_							)

							UpperCamelCase__   :Any												= [
							    '''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(UpperCamelCase_    ,   UpperCamelCase_							)

							UpperCamelCase__   :str												= ['''It was the best of times.''']
							self.assertEqual(UpperCamelCase_    ,   UpperCamelCase_							)




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :Dict												= torch.tensor([1, 2, 3, 4]							)
							UpperCamelCase__   :Optional[int]												= torch.tensor([1, 1, 1, 1]							)
							np.testing.assert_array_equal(build_mask(UpperCamelCase_    ,   0							).numpy()    ,   expected.numpy()							)




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :Tuple												= torch.tensor([1, 2, 3, 4, 23, 23, 23]							)
							UpperCamelCase__   :List[Any]												= torch.tensor([1, 1, 1, 1, 0, 0, 0]							)
							np.testing.assert_array_equal(build_mask(UpperCamelCase_    ,   23							).numpy()    ,   expected.numpy()							)




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :Tuple												= torch.tensor([8, 2, 3, 4, 1, 1, 1]							)
							UpperCamelCase__   :Tuple												= torch.tensor([1, 1, 1, 1, 0, 0, 0]							)
							np.testing.assert_array_equal(build_mask(UpperCamelCase_    ,   1							).numpy()    ,   expected.numpy()							)




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							UpperCamelCase__   :List[Any]												= 101
							UpperCamelCase__   :List[str]												= torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 101, 5, 6], [1, 101, 3, 4, 101, 6]]							)
							UpperCamelCase__   :Tuple												= torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]							)

							UpperCamelCase__   :Any												= compute_token_type_ids(UpperCamelCase_    ,   UpperCamelCase_							)
							np.testing.assert_array_equal(UpperCamelCase_    ,   UpperCamelCase_							)



'''simple docstring'''
from ...utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_torch_available,
    is_transformers_available,
)


try:
		if not (is_transformers_available() and is_torch_available()):
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
		from .multicontrolnet import MultiControlNetModel
		from .pipeline_controlnet import StableDiffusionControlNetPipeline
		from .pipeline_controlnet_imgaimg import StableDiffusionControlNetImgaImgPipeline
		from .pipeline_controlnet_inpaint import StableDiffusionControlNetInpaintPipeline


if is_transformers_available() and is_flax_available():
		from .pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline