




'''simple docstring'''


# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/

import gc
import random
import tempfile
import unittest

import numpy as np
import torch
from PIL import Image
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    ControlNetModel,
    DDIMScheduler,
    StableDiffusionControlNetImgaImgPipeline,
    UNetaDConditionModel,
)
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_controlnet import MultiControlNetModel
from diffusers.utils import floats_tensor, load_image, load_numpy, randn_tensor, slow, torch_device
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..pipeline_params import (
    IMAGE_TO_IMAGE_IMAGE_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import (
    PipelineKarrasSchedulerTesterMixin,
    PipelineLatentTesterMixin,
    PipelineTesterMixin,
)


enable_full_determinism()

class      A       (						_a	,_a	,_a	,unittest.TestCase       ):
							lowercase_							     =							StableDiffusionControlNetImgaImgPipeline
							lowercase_							     =							TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {'height', 'width'}
							lowercase_							     =							TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
							lowercase_							     =							IMAGE_TO_IMAGE_IMAGE_PARAMS.union({'control_image'}       )
							lowercase_							     =							IMAGE_TO_IMAGE_IMAGE_PARAMS







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


														"""simple docstring"""


														torch.manual_seed(0   )
														_a      	=							UNetaDConditionModel(
														    block_out_channels=(32, 64)				,     layers_per_block=2				,     sample_size=32				,     in_channels=4				,     out_channels=4				,     down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''')				,     up_block_types=('''CrossAttnUpBlock2D''', '''UpBlock2D''')				,     cross_attention_dim=32				,     )
														torch.manual_seed(0   )
														_a      	=							ControlNetModel(
														    block_out_channels=(32, 64)				,     layers_per_block=2				,     in_channels=4				,     down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''')				,     cross_attention_dim=32				,     conditioning_embedding_out_channels=(16, 32)				,     )
														torch.manual_seed(0   )
														_a      	=							DDIMScheduler(
														    beta_start=0.0_0_0_8_5				,     beta_end=0.0_1_2				,     beta_schedule='''scaled_linear'''				,     clip_sample=lowerCAmelCase_				,     set_alpha_to_one=lowerCAmelCase_				,     )
														torch.manual_seed(0   )
														_a      	=							AutoencoderKL(
														    block_out_channels=[32, 64]				,     in_channels=3				,     out_channels=3				,     down_block_types=['''DownEncoderBlock2D''', '''DownEncoderBlock2D''']				,     up_block_types=['''UpDecoderBlock2D''', '''UpDecoderBlock2D''']				,     latent_channels=4				,     )
														torch.manual_seed(0   )
														_a      	=							CLIPTextConfig(
														    bos_token_id=0				,     eos_token_id=2				,     hidden_size=32				,     intermediate_size=37				,     layer_norm_eps=1e-05				,     num_attention_heads=4				,     num_hidden_layers=5				,     pad_token_id=1				,     vocab_size=10_00				,     )
														_a      	=							CLIPTextModel(lowerCAmelCase_   )
														_a      	=							CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''   )

														_a      	=							{
														    '''unet''': unet,
														    '''controlnet''': controlnet,
														    '''scheduler''': scheduler,
														    '''vae''': vae,
														    '''text_encoder''': text_encoder,
														    '''tokenizer''': tokenizer,
														    '''safety_checker''': None,
														    '''feature_extractor''': None,
														}
														return components







							def   __lowerCAmelCase     (    self			:    Optional[int]				,     lowerCAmelCase_			:    str				,     lowerCAmelCase_			:    Optional[Any]=0   )     ->				List[Any]:


														"""simple docstring"""


														if str(lowerCAmelCase_   ).startswith('''mps'''   ):
																					_a      	=							torch.manual_seed(lowerCAmelCase_   )
														else:
																					_a      	=							torch.Generator(device=lowerCAmelCase_   ).manual_seed(lowerCAmelCase_   )

														_a      	=							2
														_a      	=							randn_tensor(
														    (1, 3, 32 * controlnet_embedder_scale_factor, 32 * controlnet_embedder_scale_factor)				,     generator=lowerCAmelCase_				,     device=torch.device(lowerCAmelCase_   )				,     )
														_a      	=							floats_tensor(control_image.shape				,     rng=random.Random(lowerCAmelCase_   )   ).to(lowerCAmelCase_   )
														_a      	=							image.cpu().permute(0				,     2				,     3				,     1   )[0]
														_a      	=							Image.fromarray(np.uinta(lowerCAmelCase_   )   ).convert('''RGB'''   ).resize((64, 64)   )
														_a      	=							{
														    '''prompt''': '''A painting of a squirrel eating a burger''',
														    '''generator''': generator,
														    '''num_inference_steps''': 2,
														    '''guidance_scale''': 6.0,
														    '''output_type''': '''numpy''',
														    '''image''': image,
														    '''control_image''': control_image,
														}

														return inputs







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


														"""simple docstring"""


														return self._test_attention_slicing_forward_pass(expected_max_diff=2e-3   )







							@unittest.skipIf(
							    torch_device != '''cuda''' or not is_xformers_available()				,     reason='''XFormers attention is only available with CUDA and `xformers` installed'''				,     )
							def   __lowerCAmelCase     (    self			:    Dict   )     ->				str:


														"""simple docstring"""


														self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=2e-3   )







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


														"""simple docstring"""


														self._test_inference_batch_single_identical(expected_max_diff=2e-3   )



class      A       (						_a	,_a	,unittest.TestCase       ):
							lowercase_							     =							StableDiffusionControlNetImgaImgPipeline
							lowercase_							     =							TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {'height', 'width'}
							lowercase_							     =							TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
							lowercase_							     =							frozenset([]       )  # TO_DO: add image_params once refactored VaeImageProcessor.preprocess







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


														"""simple docstring"""


														torch.manual_seed(0   )
														_a      	=							UNetaDConditionModel(
														    block_out_channels=(32, 64)				,     layers_per_block=2				,     sample_size=32				,     in_channels=4				,     out_channels=4				,     down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''')				,     up_block_types=('''CrossAttnUpBlock2D''', '''UpBlock2D''')				,     cross_attention_dim=32				,     )
														torch.manual_seed(0   )

														def init_weights(lowerCAmelCase_			:    List[str]   ):
																					if isinstance(lowerCAmelCase_				,     torch.nn.Convad   ):
																												torch.nn.init.normal(m.weight   )
																												m.bias.data.fill_(1.0   )

														_a      	=							ControlNetModel(
														    block_out_channels=(32, 64)				,     layers_per_block=2				,     in_channels=4				,     down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''')				,     cross_attention_dim=32				,     conditioning_embedding_out_channels=(16, 32)				,     )
														controlneta.controlnet_down_blocks.apply(lowerCAmelCase_   )

														torch.manual_seed(0   )
														_a      	=							ControlNetModel(
														    block_out_channels=(32, 64)				,     layers_per_block=2				,     in_channels=4				,     down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''')				,     cross_attention_dim=32				,     conditioning_embedding_out_channels=(16, 32)				,     )
														controlneta.controlnet_down_blocks.apply(lowerCAmelCase_   )

														torch.manual_seed(0   )
														_a      	=							DDIMScheduler(
														    beta_start=0.0_0_0_8_5				,     beta_end=0.0_1_2				,     beta_schedule='''scaled_linear'''				,     clip_sample=lowerCAmelCase_				,     set_alpha_to_one=lowerCAmelCase_				,     )
														torch.manual_seed(0   )
														_a      	=							AutoencoderKL(
														    block_out_channels=[32, 64]				,     in_channels=3				,     out_channels=3				,     down_block_types=['''DownEncoderBlock2D''', '''DownEncoderBlock2D''']				,     up_block_types=['''UpDecoderBlock2D''', '''UpDecoderBlock2D''']				,     latent_channels=4				,     )
														torch.manual_seed(0   )
														_a      	=							CLIPTextConfig(
														    bos_token_id=0				,     eos_token_id=2				,     hidden_size=32				,     intermediate_size=37				,     layer_norm_eps=1e-05				,     num_attention_heads=4				,     num_hidden_layers=5				,     pad_token_id=1				,     vocab_size=10_00				,     )
														_a      	=							CLIPTextModel(lowerCAmelCase_   )
														_a      	=							CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''   )

														_a      	=							MultiControlNetModel([controlneta, controlneta]   )

														_a      	=							{
														    '''unet''': unet,
														    '''controlnet''': controlnet,
														    '''scheduler''': scheduler,
														    '''vae''': vae,
														    '''text_encoder''': text_encoder,
														    '''tokenizer''': tokenizer,
														    '''safety_checker''': None,
														    '''feature_extractor''': None,
														}
														return components







							def   __lowerCAmelCase     (    self			:    Union[str, Any]				,     lowerCAmelCase_			:    List[Any]				,     lowerCAmelCase_			:    Union[str, Any]=0   )     ->				Tuple:


														"""simple docstring"""


														if str(lowerCAmelCase_   ).startswith('''mps'''   ):
																					_a      	=							torch.manual_seed(lowerCAmelCase_   )
														else:
																					_a      	=							torch.Generator(device=lowerCAmelCase_   ).manual_seed(lowerCAmelCase_   )

														_a      	=							2

														_a      	=							[
														    randn_tensor(
														        (1, 3, 32 * controlnet_embedder_scale_factor, 32 * controlnet_embedder_scale_factor)				,     generator=lowerCAmelCase_				,     device=torch.device(lowerCAmelCase_   )				,     ),
														    randn_tensor(
														        (1, 3, 32 * controlnet_embedder_scale_factor, 32 * controlnet_embedder_scale_factor)				,     generator=lowerCAmelCase_				,     device=torch.device(lowerCAmelCase_   )				,     ),
														]

														_a      	=							floats_tensor(control_image[0].shape				,     rng=random.Random(lowerCAmelCase_   )   ).to(lowerCAmelCase_   )
														_a      	=							image.cpu().permute(0				,     2				,     3				,     1   )[0]
														_a      	=							Image.fromarray(np.uinta(lowerCAmelCase_   )   ).convert('''RGB'''   ).resize((64, 64)   )
														_a      	=							{
														    '''prompt''': '''A painting of a squirrel eating a burger''',
														    '''generator''': generator,
														    '''num_inference_steps''': 2,
														    '''guidance_scale''': 6.0,
														    '''output_type''': '''numpy''',
														    '''image''': image,
														    '''control_image''': control_image,
														}

														return inputs







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


														"""simple docstring"""


														_a      	=							self.get_dummy_components()
														_a      	=							self.pipeline_class(**lowerCAmelCase_   )
														pipe.to(lowerCAmelCase_   )

														_a      	=							1_0.0
														_a      	=							4

														_a      	=							self.get_dummy_inputs(lowerCAmelCase_   )
														_a      	=							steps
														_a      	=							scale
														_a      	=							pipe(**lowerCAmelCase_   )[0]

														_a      	=							self.get_dummy_inputs(lowerCAmelCase_   )
														_a      	=							steps
														_a      	=							scale
														_a      	=							pipe(**lowerCAmelCase_				,     control_guidance_start=0.1				,     control_guidance_end=0.2   )[0]

														_a      	=							self.get_dummy_inputs(lowerCAmelCase_   )
														_a      	=							steps
														_a      	=							scale
														_a      	=							pipe(**lowerCAmelCase_				,     control_guidance_start=[0.1, 0.3]				,     control_guidance_end=[0.2, 0.7]   )[0]

														_a      	=							self.get_dummy_inputs(lowerCAmelCase_   )
														_a      	=							steps
														_a      	=							scale
														_a      	=							pipe(**lowerCAmelCase_				,     control_guidance_start=0.4				,     control_guidance_end=[0.5, 0.8]   )[0]

														# make sure that all outputs are different
														assert np.sum(np.abs(output_a - output_a   )   ) > 1e-3
														assert np.sum(np.abs(output_a - output_a   )   ) > 1e-3
														assert np.sum(np.abs(output_a - output_a   )   ) > 1e-3







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


														"""simple docstring"""


														return self._test_attention_slicing_forward_pass(expected_max_diff=2e-3   )







							@unittest.skipIf(
							    torch_device != '''cuda''' or not is_xformers_available()				,     reason='''XFormers attention is only available with CUDA and `xformers` installed'''				,     )
							def   __lowerCAmelCase     (    self			:    Optional[int]   )     ->				Tuple:


														"""simple docstring"""


														self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=2e-3   )







							def   __lowerCAmelCase     (    self			:    Dict   )     ->				Dict:


														"""simple docstring"""


														self._test_inference_batch_single_identical(expected_max_diff=2e-3   )







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


														"""simple docstring"""


														_a      	=							self.get_dummy_components()
														_a      	=							self.pipeline_class(**lowerCAmelCase_   )
														pipe.to(lowerCAmelCase_   )
														pipe.set_progress_bar_config(disable=lowerCAmelCase_   )
														with tempfile.TemporaryDirectory() as tmpdir:
																					try:
																												# save_pretrained is not implemented for Multi-ControlNet
																												pipe.save_pretrained(lowerCAmelCase_   )
																					except NotImplementedError:
																												pass



@slow
@require_torch_gpu
class      A       (						unittest.TestCase       ):







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


														"""simple docstring"""


														super().tearDown()
														gc.collect()
														torch.cuda.empty_cache()







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


														"""simple docstring"""


														_a      	=							ControlNetModel.from_pretrained('''lllyasviel/sd-controlnet-canny'''   )

														_a      	=							StableDiffusionControlNetImgaImgPipeline.from_pretrained(
														    '''runwayml/stable-diffusion-v1-5'''				,     safety_checker=lowerCAmelCase_				,     controlnet=lowerCAmelCase_   )
														pipe.enable_model_cpu_offload()
														pipe.set_progress_bar_config(disable=lowerCAmelCase_   )

														_a      	=							torch.Generator(device='''cpu'''   ).manual_seed(0   )
														_a      	=							'''evil space-punk bird'''
														_a      	=							load_image(
														    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/bird_canny.png'''   ).resize((5_12, 5_12)   )
														_a      	=							load_image(
														    '''https://huggingface.co/lllyasviel/sd-controlnet-canny/resolve/main/images/bird.png'''   ).resize((5_12, 5_12)   )

														_a      	=							pipe(
														    lowerCAmelCase_				,     lowerCAmelCase_				,     control_image=lowerCAmelCase_				,     generator=lowerCAmelCase_				,     output_type='''np'''				,     num_inference_steps=50				,     strength=0.6				,     )

														_a      	=							output.images[0]

														assert image.shape == (5_12, 5_12, 3)

														_a      	=							load_numpy(
														    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/img2img.npy'''   )

														assert np.abs(expected_image - image   ).max() < 9e-2







'''simple docstring'''


import json
import os
import unittest

from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast
from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers, require_torch
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin

@require_tokenizers
class      A       (						_a	,unittest.TestCase       ):
							lowercase_							     =							LEDTokenizer
							lowercase_							     =							LEDTokenizerFast
							lowercase_							     =							True







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


														"""simple docstring"""


														super().setUp()
														_a      	=							[
														    '''l''',
														    '''o''',
														    '''w''',
														    '''e''',
														    '''r''',
														    '''s''',
														    '''t''',
														    '''i''',
														    '''d''',
														    '''n''',
														    '''\u0120''',
														    '''\u0120l''',
														    '''\u0120n''',
														    '''\u0120lo''',
														    '''\u0120low''',
														    '''er''',
														    '''\u0120lowest''',
														    '''\u0120newer''',
														    '''\u0120wider''',
														    '''<unk>''',
														]
														_a      	=							dict(zip(lowerCAmelCase_				,     range(len(lowerCAmelCase_   )   )   )   )
														_a      	=							['''#version: 0.2''', '''\u0120 l''', '''\u0120l o''', '''\u0120lo w''', '''e r''', '''''']
														_a      	=							{'''unk_token''': '''<unk>'''}

														_a      	=							os.path.join(self.tmpdirname				,     VOCAB_FILES_NAMES['''vocab_file''']   )
														_a      	=							os.path.join(self.tmpdirname				,     VOCAB_FILES_NAMES['''merges_file''']   )
														with open(self.vocab_file				,     '''w'''				,     encoding='''utf-8'''   ) as fp:
																					fp.write(json.dumps(lowerCAmelCase_   ) + '''\n'''   )
														with open(self.merges_file				,     '''w'''				,     encoding='''utf-8'''   ) as fp:
																					fp.write('''\n'''.join(lowerCAmelCase_   )   )







							def   __lowerCAmelCase     (    self			:    Union[str, Any]				,     **lowerCAmelCase_			:    int   )     ->				Optional[int]:


														"""simple docstring"""


														kwargs.update(self.special_tokens_map   )
														return self.tokenizer_class.from_pretrained(self.tmpdirname				,     **lowerCAmelCase_   )







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


														"""simple docstring"""


														kwargs.update(self.special_tokens_map   )
														return self.rust_tokenizer_class.from_pretrained(self.tmpdirname				,     **lowerCAmelCase_   )







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


														"""simple docstring"""


														return "lower newer", "lower newer"







							@cached_property
							def   __lowerCAmelCase     (    self			:    Dict   )     ->				int:


														"""simple docstring"""


														return LEDTokenizer.from_pretrained('''allenai/led-base-16384'''   )







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


														"""simple docstring"""


														return LEDTokenizerFast.from_pretrained('''allenai/led-base-16384'''   )







							@require_torch
							def   __lowerCAmelCase     (    self			:    int   )     ->				Tuple:


														"""simple docstring"""


														_a      	=							['''A long paragraph for summarization.''', '''Another paragraph for summarization.''']
														_a      	=							[0, 2_50, 2_51, 1_78_18, 13, 3_91_86, 19_38, 4, 2]

														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							tokenizer(lowerCAmelCase_				,     max_length=len(lowerCAmelCase_   )				,     padding=lowerCAmelCase_				,     return_tensors='''pt'''   )
																					self.assertIsInstance(lowerCAmelCase_				,     lowerCAmelCase_   )

																					self.assertEqual((2, 9)				,     batch.input_ids.shape   )
																					self.assertEqual((2, 9)				,     batch.attention_mask.shape   )
																					_a      	=							batch.input_ids.tolist()[0]
																					self.assertListEqual(lowerCAmelCase_				,     lowerCAmelCase_   )







							@require_torch
							def   __lowerCAmelCase     (    self			:    Tuple   )     ->				List[Any]:


														"""simple docstring"""


														_a      	=							['''A long paragraph for summarization.''', '''Another paragraph for summarization.''']
														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							tokenizer(lowerCAmelCase_				,     padding=lowerCAmelCase_				,     return_tensors='''pt'''   )
																					self.assertIn('''input_ids'''				,     lowerCAmelCase_   )
																					self.assertIn('''attention_mask'''				,     lowerCAmelCase_   )
																					self.assertNotIn('''labels'''				,     lowerCAmelCase_   )
																					self.assertNotIn('''decoder_attention_mask'''				,     lowerCAmelCase_   )







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


														"""simple docstring"""


														_a      	=							[
														    '''Summary of the text.''',
														    '''Another summary.''',
														]
														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							tokenizer(text_target=lowerCAmelCase_				,     max_length=32				,     padding='''max_length'''				,     return_tensors='''pt'''   )
																					self.assertEqual(32				,     targets['''input_ids'''].shape[1]   )







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


														"""simple docstring"""


														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							tokenizer(
																					    ['''I am a small frog''' * 10_24, '''I am a small frog''']				,     padding=lowerCAmelCase_				,     truncation=lowerCAmelCase_				,     return_tensors='''pt'''   )
																					self.assertIsInstance(lowerCAmelCase_				,     lowerCAmelCase_   )
																					self.assertEqual(batch.input_ids.shape				,     (2, 51_22)   )







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


														"""simple docstring"""


														_a      	=							['''A long paragraph for summarization.''']
														_a      	=							[
														    '''Summary of the text.''',
														]
														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							tokenizer(lowerCAmelCase_				,     return_tensors='''pt'''   )
																					_a      	=							tokenizer(text_target=lowerCAmelCase_				,     return_tensors='''pt'''   )
																					_a      	=							inputs['''input_ids''']
																					_a      	=							targets['''input_ids''']
																					self.assertTrue((input_ids[:, 0] == tokenizer.bos_token_id).all().item()   )
																					self.assertTrue((labels[:, 0] == tokenizer.bos_token_id).all().item()   )
																					self.assertTrue((input_ids[:, -1] == tokenizer.eos_token_id).all().item()   )
																					self.assertTrue((labels[:, -1] == tokenizer.eos_token_id).all().item()   )







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


														"""simple docstring"""


														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							['''Summary of the text.''', '''Another summary.''']
																					_a      	=							[[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1, -1]]

																					_a      	=							tokenizer(lowerCAmelCase_				,     padding=lowerCAmelCase_   )
																					_a      	=							[[0] * len(lowerCAmelCase_   ) for x in encoded_output['''input_ids''']]
																					_a      	=							tokenizer.pad(lowerCAmelCase_   )
																					self.assertSequenceEqual(outputs['''global_attention_mask''']				,     lowerCAmelCase_   )







							def   __lowerCAmelCase     (    self			:    Any   )     ->				Dict:


														"""simple docstring"""


														pass







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


														"""simple docstring"""


														for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
																					with self.subTest(F'{tokenizer.__class__.__name__} ({pretrained_name})'   ):
																												_a      	=							self.rust_tokenizer_class.from_pretrained(lowerCAmelCase_				,     **lowerCAmelCase_   )
																												_a      	=							self.tokenizer_class.from_pretrained(lowerCAmelCase_				,     **lowerCAmelCase_   )
																												_a      	=							'''A, <mask> AllenNLP sentence.'''
																												_a      	=							tokenizer_r.encode_plus(lowerCAmelCase_				,     add_special_tokens=lowerCAmelCase_				,     return_token_type_ids=lowerCAmelCase_   )
																												_a      	=							tokenizer_p.encode_plus(lowerCAmelCase_				,     add_special_tokens=lowerCAmelCase_				,     return_token_type_ids=lowerCAmelCase_   )
																												self.assertEqual(sum(tokens_r['''token_type_ids''']   )				,     sum(tokens_p['''token_type_ids''']   )   )
																												self.assertEqual(
																												    sum(tokens_r['''attention_mask''']   ) / len(tokens_r['''attention_mask''']   )				,     sum(tokens_p['''attention_mask''']   ) / len(tokens_p['''attention_mask''']   )				,     )

																												_a      	=							tokenizer_r.convert_ids_to_tokens(tokens_r['''input_ids''']   )
																												_a      	=							tokenizer_p.convert_ids_to_tokens(tokens_p['''input_ids''']   )
																												self.assertSequenceEqual(tokens_p['''input_ids''']				,     [0, 2_50, 6, 5_02_64, 38_23, 4_87, 2_19_92, 36_45, 4, 2]   )
																												self.assertSequenceEqual(tokens_r['''input_ids''']				,     [0, 2_50, 6, 5_02_64, 38_23, 4_87, 2_19_92, 36_45, 4, 2]   )

																												self.assertSequenceEqual(
																												    lowerCAmelCase_				,     ['''<s>''', '''A''', ''',''', '''<mask>''', '''ĠAllen''', '''N''', '''LP''', '''Ġsentence''', '''.''', '''</s>''']   )
																												self.assertSequenceEqual(
																												    lowerCAmelCase_				,     ['''<s>''', '''A''', ''',''', '''<mask>''', '''ĠAllen''', '''N''', '''LP''', '''Ġsentence''', '''.''', '''</s>''']   )

