code: 
  
  
  
  """simple docstring"""
  import inspect
  import unittest
  
  from transformers import SwinaSRConfig
  from transformers.testing_utils import require_torch, require_vision, slow, torch_device
  from transformers.utils import is_torch_available, is_vision_available
  
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
  
  
  if is_torch_available():
  		import torch
  		from torch import nn
  
  		from transformers import SwinaSRForImageSuperResolution, SwinaSRModel
  		from transformers.models.swinasr.modeling_swinasr import SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST
  
  if is_vision_available():
  		from PIL import Image
  
  		from transformers import SwinaSRImageProcessor
  class 							_UpperCAmelCase							:
  
  
  
  
  
  					'''simple docstring'''
  
  
  
  					def __init__(      self ,			A ,			A=1_3 ,			A=3_2 ,			A=1 ,			A=3 ,			A=1_6 ,			A=[1, 2, 1] ,			A=[2, 2, 4] ,			A=2 ,			A=2.0 ,			A=True ,			A=0.0 ,			A=0.0 ,			A=0.1 ,			A="gelu" ,			A=False ,			A=True ,			A=0.02 ,			A=1E-5 ,			A=True ,			A=None ,			A=False ,			A=2 ,			)							->      List[Any]:
  									_UpperCAmelCase							:						Optional[int]       							=					parent
  									_UpperCAmelCase							:						Tuple       							=					batch_size
  									_UpperCAmelCase							:						Optional[Any]       							=					image_size
  									_UpperCAmelCase							:						int       							=					patch_size
  									_UpperCAmelCase							:						Optional[int]       							=					num_channels
  									_UpperCAmelCase							:						int       							=					embed_dim
  									_UpperCAmelCase							:						Union[str, Any]       							=					depths
  									_UpperCAmelCase							:						Optional[Any]       							=					num_heads
  									_UpperCAmelCase							:						Optional[int]       							=					window_size
  									_UpperCAmelCase							:						str       							=					mlp_ratio
  									_UpperCAmelCase							:						Optional[Any]       							=					qkv_bias
  									_UpperCAmelCase							:						int       							=					hidden_dropout_prob
  									_UpperCAmelCase							:						Union[str, Any]       							=					attention_probs_dropout_prob
  									_UpperCAmelCase							:						int       							=					drop_path_rate
  									_UpperCAmelCase							:						Any       							=					hidden_act
  									_UpperCAmelCase							:						Any       							=					use_absolute_embeddings
  									_UpperCAmelCase							:						List[Any]       							=					patch_norm
  									_UpperCAmelCase							:						str       							=					layer_norm_eps
  									_UpperCAmelCase							:						Any       							=					initializer_range
  									_UpperCAmelCase							:						Tuple       							=					is_training
  									_UpperCAmelCase							:						Union[str, Any]       							=					scope
  									_UpperCAmelCase							:						str       							=					use_labels
  									_UpperCAmelCase							:						Dict       							=					upscale
  
  									# here we set some attributes to make tests pass
  									_UpperCAmelCase							:						Dict       							=					len(__SCREAMING_SNAKE_CASE	)
  									_UpperCAmelCase							:						Any       							=					embed_dim
  									_UpperCAmelCase							:						Dict       							=					(image_size // patch_size) ** 2
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      Dict:
  									_UpperCAmelCase							:						Optional[Any]       							=					floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]	)
  
  									_UpperCAmelCase							:						Tuple       							=					None
  									if self.use_labels:
  													_UpperCAmelCase							:						Optional[int]       							=					ids_tensor([self.batch_size] ,			self.type_sequence_label_size	)
  
  									_UpperCAmelCase							:						Optional[int]       							=					self.get_config()
  
  									return config, pixel_values, labels
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      int:
  									return SwinaSRConfig(
  									    image_size=self.image_size ,			patch_size=self.patch_size ,			num_channels=self.num_channels ,			embed_dim=self.embed_dim ,			depths=self.depths ,			num_heads=self.num_heads ,			window_size=self.window_size ,			mlp_ratio=self.mlp_ratio ,			qkv_bias=self.qkv_bias ,			hidden_dropout_prob=self.hidden_dropout_prob ,			attention_probs_dropout_prob=self.attention_probs_dropout_prob ,			drop_path_rate=self.drop_path_rate ,			hidden_act=self.hidden_act ,			use_absolute_embeddings=self.use_absolute_embeddings ,			path_norm=self.patch_norm ,			layer_norm_eps=self.layer_norm_eps ,			initializer_range=self.initializer_range ,			upscale=self.upscale ,			)
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self ,			A ,			A ,			A	)							->      Optional[Any]:
  									_UpperCAmelCase							:						Tuple       							=					SwinaSRModel(config=__SCREAMING_SNAKE_CASE	)
  									model.to(__SCREAMING_SNAKE_CASE	)
  									model.eval()
  									_UpperCAmelCase							:						Tuple       							=					model(__SCREAMING_SNAKE_CASE	)
  
  									self.parent.assertEqual(
  									    result.last_hidden_state.shape ,			(self.batch_size, self.embed_dim, self.image_size, self.image_size)	)
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self ,			A ,			A ,			A	)							->      Optional[int]:
  									_UpperCAmelCase							:						str       							=					SwinaSRForImageSuperResolution(__SCREAMING_SNAKE_CASE	)
  									model.to(__SCREAMING_SNAKE_CASE	)
  									model.eval()
  									_UpperCAmelCase							:						Any       							=					model(__SCREAMING_SNAKE_CASE	)
  
  									_UpperCAmelCase							:						Optional[Any]       							=					self.image_size * self.upscale
  									self.parent.assertEqual(
  									    result.reconstruction.shape ,			(self.batch_size, self.num_channels, expected_image_size, expected_image_size)	)
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      int:
  									_UpperCAmelCase							:						Union[str, Any]       							=					self.prepare_config_and_inputs()
  									_UpperCAmelCase							,       _UpperCAmelCase							,       _UpperCAmelCase							:						Any       							=					config_and_inputs
  									_UpperCAmelCase							:						Optional[Any]       							=					{'''pixel_values''': pixel_values}
  									return config, inputs_dict
  
  
  
  @require_torch
  class 							_UpperCAmelCase							(				lowerCAmelCase_	,lowerCAmelCase_	,unittest.TestCase   ):
  
  
  
  
  
  					'''simple docstring'''
  
  
  
  					a__             =(SwinaSRModel, SwinaSRForImageSuperResolution) if is_torch_available() else ()
  					a__             ={"""feature-extraction""": SwinaSRModel} if is_torch_available() else {}
  
  					a__             =False
  					a__             =False
  					a__             =False
  					a__             =False
  					a__             =False
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      int:
  									_UpperCAmelCase							:						str       							=					SwinaSRModelTester(self	)
  									_UpperCAmelCase							:						Dict       							=					ConfigTester(self ,			config_class=__SCREAMING_SNAKE_CASE ,			embed_dim=3_7	)
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      Dict:
  									self.config_tester.create_and_test_config_to_json_string()
  									self.config_tester.create_and_test_config_to_json_file()
  									self.config_tester.create_and_test_config_from_and_save_pretrained()
  									self.config_tester.create_and_test_config_with_num_labels()
  									self.config_tester.check_config_can_be_init_without_params()
  									self.config_tester.check_config_arguments_init()
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      Any:
  									_UpperCAmelCase							:						Tuple       							=					self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_model(*__SCREAMING_SNAKE_CASE	)
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      Dict:
  									_UpperCAmelCase							:						Dict       							=					self.model_tester.prepare_config_and_inputs()
  									self.model_tester.create_and_check_for_image_super_resolution(*__SCREAMING_SNAKE_CASE	)
  
  
  
  
  
  					@unittest.skip(reason='''Got `CUDA error: misaligned address` with PyTorch 2.0.0.'''	)
  					def 				__lowerCAmelCase			(      self	)							->      Optional[Any]:
  									pass
  
  
  
  
  
  					@unittest.skip(reason='''Swin2SR does not use inputs_embeds'''	)
  					def 				__lowerCAmelCase			(      self	)							->      Optional[Any]:
  									pass
  
  
  
  
  
  					@unittest.skip(reason='''Swin2SR does not support training yet'''	)
  					def 				__lowerCAmelCase			(      self	)							->      int:
  									pass
  
  
  
  
  
  					@unittest.skip(reason='''Swin2SR does not support training yet'''	)
  					def 				__lowerCAmelCase			(      self	)							->      Any:
  									pass
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      Union[str, Any]:
  									_UpperCAmelCase							,       _UpperCAmelCase							:						List[Any]       							=					self.model_tester.prepare_config_and_inputs_for_common()
  
  									for model_class in self.all_model_classes:
  													_UpperCAmelCase							:						int       							=					model_class(__SCREAMING_SNAKE_CASE	)
  													self.assertIsInstance(model.get_input_embeddings() ,			(nn.Module)	)
  													_UpperCAmelCase							:						Optional[int]       							=					model.get_output_embeddings()
  													self.assertTrue(x is None or isinstance(__SCREAMING_SNAKE_CASE ,			nn.Linear	)	)
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      Tuple:
  									_UpperCAmelCase							,       _UpperCAmelCase							:						List[str]       							=					self.model_tester.prepare_config_and_inputs_for_common()
  
  									for model_class in self.all_model_classes:
  													_UpperCAmelCase							:						str       							=					model_class(__SCREAMING_SNAKE_CASE	)
  													_UpperCAmelCase							:						str       							=					inspect.signature(model.forward	)
  													# signature.parameters is an OrderedDict => so arg_names order is deterministic
  													_UpperCAmelCase							:						Any       							=					[*signature.parameters.keys()]
  
  													_UpperCAmelCase							:						int       							=					['''pixel_values''']
  													self.assertListEqual(arg_names[:1] ,			__SCREAMING_SNAKE_CASE	)
  
  
  
  
  
  					@slow
  					def 				__lowerCAmelCase			(      self	)							->      Tuple:
  
  									for model_name in SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
  													_UpperCAmelCase							:						List[Any]       							=					SwinaSRModel.from_pretrained(__SCREAMING_SNAKE_CASE	)
  													self.assertIsNotNone(__SCREAMING_SNAKE_CASE	)
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      Dict:
  									_UpperCAmelCase							,       _UpperCAmelCase							:						Tuple       							=					self.model_tester.prepare_config_and_inputs_for_common()
  
  									_UpperCAmelCase							:						Dict       							=					_config_zero_init(__SCREAMING_SNAKE_CASE	)
  									for model_class in self.all_model_classes:
  													_UpperCAmelCase							:						Optional[Any]       							=					model_class(config=__SCREAMING_SNAKE_CASE	)
  													for name, param in model.named_parameters():
  																	if "logit_scale" in name:
  																					continue
  																	if param.requires_grad:
  																					self.assertIn(
  																					    ((param.data.mean() * 1E9).round() / 1E9).item() ,			[0.0, 1.0] ,			msg=f'Parameter {name} of model {model_class} seems not properly initialized' ,			)
  
  
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      int:
  									_UpperCAmelCase							,       _UpperCAmelCase							:						int       							=					self.model_tester.prepare_config_and_inputs_for_common()
  									_UpperCAmelCase							:						List[str]       							=					True
  
  									for model_class in self.all_model_classes:
  													_UpperCAmelCase							:						int       							=					True
  													_UpperCAmelCase							:						Tuple       							=					False
  													_UpperCAmelCase							:						int       							=					True
  													_UpperCAmelCase							:						Tuple       							=					model_class(__SCREAMING_SNAKE_CASE	)
  													model.to(__SCREAMING_SNAKE_CASE	)
  													model.eval()
  													with torch.no_grad():
  																	_UpperCAmelCase							:						int       							=					model(**self._prepare_for_class(__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE	)	)
  													_UpperCAmelCase							:						Any       							=					outputs.attentions
  													_UpperCAmelCase							:						Union[str, Any]       							=					len(self.model_tester.depths	)
  													self.assertEqual(len(__SCREAMING_SNAKE_CASE	) ,			__SCREAMING_SNAKE_CASE	)
  
  													# check that output_attentions also work using config
  													del inputs_dict["output_attentions"]
  													_UpperCAmelCase							:						List[str]       							=					True
  													_UpperCAmelCase							:						str       							=					config.window_size**2
  													_UpperCAmelCase							:						int       							=					model_class(__SCREAMING_SNAKE_CASE	)
  													model.to(__SCREAMING_SNAKE_CASE	)
  													model.eval()
  													with torch.no_grad():
  																	_UpperCAmelCase							:						Dict       							=					model(**self._prepare_for_class(__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE	)	)
  													_UpperCAmelCase							:						List[Any]       							=					outputs.attentions
  													self.assertEqual(len(__SCREAMING_SNAKE_CASE	) ,			__SCREAMING_SNAKE_CASE	)
  
  													self.assertListEqual(
  													    list(attentions[0].shape[-3:]	) ,			[self.model_tester.num_heads[0], window_size_squared, window_size_squared] ,			)
  													_UpperCAmelCase							:						Optional[int]       							=					len(__SCREAMING_SNAKE_CASE	)
  
  													# Check attention is always last and order is fine
  													_UpperCAmelCase							:						List[str]       							=					True
  													_UpperCAmelCase							:						Dict       							=					True
  													_UpperCAmelCase							:						Any       							=					model_class(__SCREAMING_SNAKE_CASE	)
  													model.to(__SCREAMING_SNAKE_CASE	)
  													model.eval()
  													with torch.no_grad():
  																	_UpperCAmelCase							:						int       							=					model(**self._prepare_for_class(__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE	)	)
  
  													self.assertEqual(out_len + 1 ,			len(__SCREAMING_SNAKE_CASE	)	)
  
  													_UpperCAmelCase							:						int       							=					outputs.attentions
  
  													self.assertEqual(len(__SCREAMING_SNAKE_CASE	) ,			__SCREAMING_SNAKE_CASE	)
  
  													self.assertListEqual(
  													    list(self_attentions[0].shape[-3:]	) ,			[self.model_tester.num_heads[0], window_size_squared, window_size_squared] ,			)
  
  
  
  @require_vision
  @require_torch
  @slow
  class 							_UpperCAmelCase							(				unittest.TestCase   ):
  
  
  
  
  
  					'''simple docstring'''
  
  
  
  					def 				__lowerCAmelCase			(      self	)							->      Dict:
  									_UpperCAmelCase							:						List[str]       							=					SwinaSRImageProcessor()
  									_UpperCAmelCase							:						Optional[int]       							=					SwinaSRForImageSuperResolution.from_pretrained('''caidas/swin2SR-classical-sr-x2-64'''	).to(__SCREAMING_SNAKE_CASE	)
  
  									_UpperCAmelCase							:						List[Any]       							=					Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''	)
  									_UpperCAmelCase							:						Optional[int]       							=					processor(images=__SCREAMING_SNAKE_CASE ,			return_tensors='''pt'''	).to(__SCREAMING_SNAKE_CASE	)
  
  									# forward pass
  									with torch.no_grad():
  													_UpperCAmelCase							:						Dict       							=					model(**__SCREAMING_SNAKE_CASE	)
  
  									# verify the logits
  									_UpperCAmelCase							:						str       							=					torch.Size([1, 3, 9_7_6, 1_2_9_6]	)
  									self.assertEqual(outputs.reconstruction.shape ,			__SCREAMING_SNAKE_CASE	)
  									_UpperCAmelCase							:						List[str]       							=					torch.tensor(
  									    [[0.5_458, 0.5_546, 0.5_638], [0.5_526, 0.5_565, 0.5_651], [0.5_396, 0.5_426, 0.5_621]]	).to(__SCREAMING_SNAKE_CASE	)
  									self.assertTrue(torch.allclose(outputs.reconstruction[0, 0, :3, :3] ,			__SCREAMING_SNAKE_CASE ,			atol=1E-4	)	)
  
  
  
style_context: 
  
  
  
  """simple docstring"""
  import os
  from typing import List, Union
  
  import tensorflow as tf
  from tensorflow_text import BertTokenizer as BertTokenizerLayer
  from tensorflow_text import FastBertTokenizer, ShrinkLongestTrimmer, case_fold_utfa, combine_segments, pad_model_inputs
  
  from .tokenization_bert import BertTokenizer
  class 							_UpperCAmelCase							(				tf.keras.layers.Layer   ):
  
  
  
  
  
       '''simple docstring'''
  
  
  
       def __init__(      self ,			A ,			A ,			A = None ,			A = None ,			A = None ,			A = "longest" ,			A = True ,			A = 5_1_2 ,			A = None ,			A = True ,			A = True ,			A = True ,			**A ,			)							->      Tuple:
           super().__init__()
           if use_fast_bert_tokenizer:
               _UpperCAmelCase							:						Union[str, Any]       							=					FastBertTokenizer(
                   A ,			token_out_type=tf.intaa ,			lower_case_nfd_strip_accents=A ,			**A	)
           else:
               _UpperCAmelCase							:						List[Any]       							=					tf.lookup.StaticVocabularyTable(
                   tf.lookup.KeyValueTensorInitializer(
                       keys=A ,			key_dtype=tf.string ,			values=tf.range(tf.size(A ,			out_type=tf.intaa	) ,			dtype=tf.intaa	) ,			value_dtype=tf.intaa ,			) ,			num_oov_buckets=1 ,			)
               _UpperCAmelCase							:						str       							=					BertTokenizerLayer(
                   A ,			token_out_type=tf.intaa ,			lower_case=A ,			**A	)
  
           _UpperCAmelCase							:						int       							=					vocab_list
           _UpperCAmelCase							:						Dict       							=					do_lower_case
           _UpperCAmelCase							:						Optional[int]       							=					cls_token_id or vocab_list.index('''[CLS]'''	)
           _UpperCAmelCase							:						Any       							=					sep_token_id or vocab_list.index('''[SEP]'''	)
           _UpperCAmelCase							:						List[Any]       							=					pad_token_id or vocab_list.index('''[PAD]'''	)
           _UpperCAmelCase							:						List[str]       							=					ShrinkLongestTrimmer(max_length - 3 ,			axis=1	)  # Allow room for special tokens
           _UpperCAmelCase							:						Tuple       							=					max_length
           _UpperCAmelCase							:						List[Any]       							=					padding
           _UpperCAmelCase							:						List[Any]       							=					truncation
           _UpperCAmelCase							:						Union[str, Any]       							=					pad_to_multiple_of
           _UpperCAmelCase							:						Union[str, Any]       							=					return_token_type_ids
           _UpperCAmelCase							:						Union[str, Any]       							=					return_attention_mask
  
  
  
  
  
       @classmethod
       def 				__lowerCAmelCase			(      cls ,			A ,			**A	)							->      Dict:  # noqa: F821
           _UpperCAmelCase							:						Optional[int]       							=					kwargs.pop('''do_lower_case''' ,			A	)
           _UpperCAmelCase							:						int       							=					tokenizer.do_lower_case if do_lower_case is None else do_lower_case
           _UpperCAmelCase							:						Optional[Any]       							=					kwargs.pop('''cls_token_id''' ,			A	)
           _UpperCAmelCase							:						str       							=					tokenizer.cls_token_id if cls_token_id is None else cls_token_id
           _UpperCAmelCase							:						str       							=					kwargs.pop('''sep_token_id''' ,			A	)
           _UpperCAmelCase							:						int       							=					tokenizer.sep_token_id if sep_token_id is None else sep_token_id
           _UpperCAmelCase							:						List[Any]       							=					kwargs.pop('''pad_token_id''' ,			A	)
           _UpperCAmelCase							:						Optional[Any]       							=					tokenizer.pad_token_id if pad_token_id is None else pad_token_id
  
           _UpperCAmelCase							:						int       							=					tokenizer.get_vocab()
           _UpperCAmelCase							:						List[str]       							=					sorted([(wordpiece, idx) for wordpiece, idx in vocab.items()] ,			key=lambda A	: x[1]	)
           _UpperCAmelCase							:						Dict       							=					[entry[0] for entry in vocab]
           return cls(
               vocab_list=A ,			do_lower_case=A ,			cls_token_id=A ,			sep_token_id=A ,			pad_token_id=A ,			**A ,			)
  
  
  
  
  
       @classmethod
       def 				__lowerCAmelCase			(      cls ,			A ,			*A ,			**A	)							->      int:
           try:
               _UpperCAmelCase							:						int       							=					BertTokenizer.from_pretrained(A ,			*A ,			**A	)
           except:  # noqa: E722
               from .tokenization_bert_fast import BertTokenizerFast
  
               _UpperCAmelCase							:						Dict       							=					BertTokenizerFast.from_pretrained(A ,			*A ,			**A	)
           return cls.from_tokenizer(A ,			**A	)
  
  
  
  
  
       def 				__lowerCAmelCase			(      self ,			A	)							->      Any:
           if self.do_lower_case:
               _UpperCAmelCase							:						int       							=					case_fold_utfa(A	)
           _UpperCAmelCase							:						str       							=					self.tf_tokenizer.tokenize(A	)
           return tokens.merge_dims(1 ,			-1	)
  
  
  
  
  
       def 				__lowerCAmelCase			(      self ,			A ,			A=None ,			A=None ,			A=None ,			A=None ,			A=None ,			A=None ,			A=None ,			)							->      Optional[Any]:
           if padding is None:
               _UpperCAmelCase							:						str       							=					self.padding
           if padding not in ("longest", "max_length"):
               raise ValueError('''Padding must be either \'longest\' or \'max_length\'!'''	)
           if max_length is not None and text_pair is not None:
               # Because we have to instantiate a Trimmer to do it properly
               raise ValueError('''max_length cannot be overridden at call time when truncating paired texts!'''	)
           if max_length is None:
               _UpperCAmelCase							:						Union[str, Any]       							=					self.max_length
           if truncation is None:
               _UpperCAmelCase							:						List[Any]       							=					self.truncation
           if pad_to_multiple_of is None:
               _UpperCAmelCase							:						List[Any]       							=					self.pad_to_multiple_of
           if return_token_type_ids is None:
               _UpperCAmelCase							:						List[str]       							=					self.return_token_type_ids
           if return_attention_mask is None:
               _UpperCAmelCase							:						Any       							=					self.return_attention_mask
           if not isinstance(A ,			tf.Tensor	):
               _UpperCAmelCase							:						Dict       							=					tf.convert_to_tensor(A	)
           if text_pair is not None and not isinstance(A ,			tf.Tensor	):
               _UpperCAmelCase							:						str       							=					tf.convert_to_tensor(A	)
           if text_pair is not None:
               if text.shape.rank > 1:
                   raise ValueError('''text argument should not be multidimensional when a text pair is supplied!'''	)
               if text_pair.shape.rank > 1:
                   raise ValueError('''text_pair should not be multidimensional!'''	)
           if text.shape.rank == 2:
               _UpperCAmelCase							,       _UpperCAmelCase							:						str       							=					text[:, 0], text[:, 1]
           _UpperCAmelCase							:						Optional[Any]       							=					self.unpaired_tokenize(A	)
           if text_pair is None:  # Unpaired text
               if truncation:
                   _UpperCAmelCase							:						Optional[int]       							=					text[:, : max_length - 2]  # Allow room for special tokens
               _UpperCAmelCase							,       _UpperCAmelCase							:						Any       							=					combine_segments(
                   (text,) ,			start_of_sequence_id=self.cls_token_id ,			end_of_segment_id=self.sep_token_id	)
           else:  # Paired text
               _UpperCAmelCase							:						Tuple       							=					self.unpaired_tokenize(A	)
               if truncation:
                   _UpperCAmelCase							,       _UpperCAmelCase							:						Optional[int]       							=					self.paired_trimmer.trim([text, text_pair]	)
               _UpperCAmelCase							,       _UpperCAmelCase							:						Union[str, Any]       							=					combine_segments(
                   (text, text_pair) ,			start_of_sequence_id=self.cls_token_id ,			end_of_segment_id=self.sep_token_id	)
           if padding == "longest":
               _UpperCAmelCase							:						List[Any]       							=					input_ids.bounding_shape(axis=1	)
               if pad_to_multiple_of is not None:
                   # No ceiling division in tensorflow, so we negate floordiv instead
                   _UpperCAmelCase							:						Tuple       							=					pad_to_multiple_of * (-tf.math.floordiv(-pad_length ,			A	))
           else:
               _UpperCAmelCase							:						int       							=					max_length
  
           _UpperCAmelCase							,       _UpperCAmelCase							:						Any       							=					pad_model_inputs(A ,			max_seq_length=A ,			pad_value=self.pad_token_id	)
           _UpperCAmelCase							:						Dict       							=					{'''input_ids''': input_ids}
           if return_attention_mask:
               _UpperCAmelCase							:						Optional[int]       							=					attention_mask
           if return_token_type_ids:
               _UpperCAmelCase							,       _UpperCAmelCase							:						Tuple       							=					pad_model_inputs(
                   A ,			max_seq_length=A ,			pad_value=self.pad_token_id	)
               _UpperCAmelCase							:						int       							=					token_type_ids
           return output
  
  
  
  
  
       def 				__lowerCAmelCase			(      self	)							->      List[str]:
           return {
               "vocab_list": self.vocab_list,
               "do_lower_case": self.do_lower_case,
               "cls_token_id": self.cls_token_id,
               "sep_token_id": self.sep_token_id,
               "pad_token_id": self.pad_token_id,
           }
  
  
  