
import json
import unittest

import numpy as np
from huggingface_hub import hf_hub_download

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
			import torch

			if is_vision_available():
						from transformers import OneFormerImageProcessor
						from transformers.models.oneformer.image_processing_oneformer import binary_mask_to_rle
						from transformers.models.oneformer.modeling_oneformer import OneFormerForUniversalSegmentationOutput

if is_vision_available():
			from PIL import Image






def    lowerCamelCase__				(				__lowerCAmelCase  :  Union[str, Any]    ,							__lowerCAmelCase  :  Any="shi-labs/oneformer_demo"				):




			"""simple docstring"""


			with open(hf_hub_download(snake_case__    ,							snake_case__    ,							repo_type="dataset"				)    ,							"r"				) as f:
						lowerCAmelCase_						=	json.load(snake_case__				)
			lowerCAmelCase_						=	{}
			lowerCAmelCase_						=	[]
			lowerCAmelCase_						=	[]
			for key, info in class_info.items():
						lowerCAmelCase_						=	info['name']
						class_names.append(info["name"]				)
						if info["isthing"]:
									thing_ids.append(int(snake_case__				)				)
			lowerCAmelCase_						=	thing_ids
			lowerCAmelCase_						=	class_names
			return metadata





class 	_lowerCAmelCase					(	unittest.TestCase       ):




				def __init__(					self				,				_UpperCamelCase				,				_UpperCamelCase=7				,				_UpperCamelCase=3				,				_UpperCamelCase=30				,				_UpperCamelCase=400				,				_UpperCamelCase=None				,				_UpperCamelCase=True				,				_UpperCamelCase=True				,				_UpperCamelCase=[0.5, 0.5, 0.5]				,				_UpperCamelCase=[0.5, 0.5, 0.5]				,				_UpperCamelCase=10				,				_UpperCamelCase=False				,				_UpperCamelCase=255				,				_UpperCamelCase="shi-labs/oneformer_demo"				,				_UpperCamelCase="ade20k_panoptic.json"				,				_UpperCamelCase=10				,				)				->      List[str]:
							lowerCAmelCase_						=	parent
							lowerCAmelCase_						=	batch_size
							lowerCAmelCase_						=	num_channels
							lowerCAmelCase_						=	min_resolution
							lowerCAmelCase_						=	max_resolution
							lowerCAmelCase_						=	do_resize
							lowerCAmelCase_						=	{'shortest_edge': 32, 'longest_edge': 1_333} if size is None else size
							lowerCAmelCase_						=	do_normalize
							lowerCAmelCase_						=	image_mean
							lowerCAmelCase_						=	image_std
							lowerCAmelCase_						=	class_info_file
							lowerCAmelCase_						=	prepare_metadata(SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_     )
							lowerCAmelCase_						=	num_text
							lowerCAmelCase_						=	repo_path

							# for the post_process_functions
							lowerCAmelCase_						=	2
							lowerCAmelCase_						=	10
							lowerCAmelCase_						=	10
							lowerCAmelCase_						=	3
							lowerCAmelCase_						=	4
							lowerCAmelCase_						=	num_labels
							lowerCAmelCase_						=	do_reduce_labels
							lowerCAmelCase_						=	ignore_index




				def      __a						(					self     )				->      List[Any]:
							return {
							    "do_resize": self.do_resize,
							    "size": self.size,
							    "do_normalize": self.do_normalize,
							    "image_mean": self.image_mean,
							    "image_std": self.image_std,
							    "num_labels": self.num_labels,
							    "do_reduce_labels": self.do_reduce_labels,
							    "ignore_index": self.ignore_index,
							    "class_info_file": self.class_info_file,
							    "metadata": self.metadata,
							    "num_text": self.num_text,
							}




				def      __a						(					self				,				_UpperCamelCase				,				_UpperCamelCase=False     )				->      Union[str, Any]:
							if not batched:
										lowerCAmelCase_						=	image_inputs[0]
										if isinstance(SCREAMING_SNAKE_CASE_				,				Image.Image     ):
													lowerCAmelCase_						=	image.size
										else:
													lowerCAmelCase_						=	image.shape[1], image.shape[2]
										if w < h:
													lowerCAmelCase_						=	int(self.size["shortest_edge"] * h / w     )
													lowerCAmelCase_						=	self.size['shortest_edge']
										elif w > h:
													lowerCAmelCase_						=	self.size['shortest_edge']
													lowerCAmelCase_						=	int(self.size["shortest_edge"] * w / h     )
										else:
													lowerCAmelCase_						=	self.size['shortest_edge']
													lowerCAmelCase_						=	self.size['shortest_edge']

							else:
										lowerCAmelCase_						=	[]
										for image in image_inputs:
													lowerCAmelCase_						=	self.get_expected_values([image]     )
													expected_values.append((expected_height, expected_width)     )
										lowerCAmelCase_						=	max(SCREAMING_SNAKE_CASE_				,				key=lambda _UpperCamelCase     : item[0]     )[0]
										lowerCAmelCase_						=	max(SCREAMING_SNAKE_CASE_				,				key=lambda _UpperCamelCase     : item[1]     )[1]

							return expected_height, expected_width




				def      __a						(					self     )				->      int:
							return OneFormerForUniversalSegmentationOutput(
							    # +1 for null class
							    class_queries_logits=torch.randn((self.batch_size, self.num_queries, self.num_classes + 1)     )				,				masks_queries_logits=torch.randn((self.batch_size, self.num_queries, self.height, self.width)     )				,				)





@require_torch
@require_vision
class 	_lowerCAmelCase					(	a__					,      unittest.TestCase       ):
				_lowercase					=OneFormerImageProcessor if (is_vision_available() and is_torch_available()) else None
				# only for test_image_processing_common.test_image_proc_to_json_string
				_lowercase					=image_processing_class




				def      __a						(					self     )				->      List[str]:
							lowerCAmelCase_						=	OneFormerImageProcessorTester(self     )




				@property
				def      __a						(					self     )				->      int:
							return self.image_processing_tester.prepare_image_processor_dict()




				def      __a						(					self     )				->      List[str]:
							lowerCAmelCase_						=	self.image_processing_class(**self.image_processor_dict     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"image_mean"     )     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"image_std"     )     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"do_normalize"     )     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"do_resize"     )     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"size"     )     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"ignore_index"     )     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"class_info_file"     )     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"num_text"     )     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"repo_path"     )     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"metadata"     )     )
							self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,				"do_reduce_labels"     )     )




				def      __a						(					self     )				->      Optional[int]:
							pass




				def      __a						(					self     )				->      Optional[Any]:
							# Initialize image_processor
							lowerCAmelCase_						=	self.image_processing_class(**self.image_processor_dict     )
							# create random PIL images
							lowerCAmelCase_						=	prepare_image_inputs(self.image_processing_tester				,				equal_resolution=SCREAMING_SNAKE_CASE_     )
							for image in image_inputs:
										self.assertIsInstance(SCREAMING_SNAKE_CASE_				,				Image.Image     )

							# Test not batched input
							lowerCAmelCase_						=	image_processor(image_inputs[0]				,				["semantic"]				,				return_tensors="pt"     ).pixel_values

							lowerCAmelCase_						=	self.image_processing_tester.get_expected_values(SCREAMING_SNAKE_CASE_     )

							self.assertEqual(
							    encoded_images.shape				,				(1, self.image_processing_tester.num_channels, expected_height, expected_width)				,				)

							# Test batched
							lowerCAmelCase_						=	self.image_processing_tester.get_expected_values(SCREAMING_SNAKE_CASE_				,				batched=SCREAMING_SNAKE_CASE_     )

							lowerCAmelCase_						=	image_processor(
							    SCREAMING_SNAKE_CASE_				,				["semantic"] * len(SCREAMING_SNAKE_CASE_     )				,				return_tensors="pt"     ).pixel_values
							self.assertEqual(
							    encoded_images.shape				,				(
							        self.image_processing_tester.batch_size,
							        self.image_processing_tester.num_channels,
							        expected_height,
							        expected_width,
							    )				,				)




				def      __a						(					self     )				->      Optional[int]:
							# Initialize image_processor
							lowerCAmelCase_						=	self.image_processing_class(**self.image_processor_dict     )
							# create random numpy tensors
							lowerCAmelCase_						=	prepare_image_inputs(self.image_processing_tester				,				equal_resolution=SCREAMING_SNAKE_CASE_				,				numpify=SCREAMING_SNAKE_CASE_     )
							for image in image_inputs:
										self.assertIsInstance(SCREAMING_SNAKE_CASE_				,				np.ndarray     )

							# Test not batched input
							lowerCAmelCase_						=	image_processor(image_inputs[0]				,				["semantic"]				,				return_tensors="pt"     ).pixel_values

							lowerCAmelCase_						=	self.image_processing_tester.get_expected_values(SCREAMING_SNAKE_CASE_     )

							self.assertEqual(
							    encoded_images.shape				,				(1, self.image_processing_tester.num_channels, expected_height, expected_width)				,				)

							# Test batched
							lowerCAmelCase_						=	self.image_processing_tester.get_expected_values(SCREAMING_SNAKE_CASE_				,				batched=SCREAMING_SNAKE_CASE_     )

							lowerCAmelCase_						=	image_processor(
							    SCREAMING_SNAKE_CASE_				,				["semantic"] * len(SCREAMING_SNAKE_CASE_     )				,				return_tensors="pt"     ).pixel_values
							self.assertEqual(
							    encoded_images.shape				,				(
							        self.image_processing_tester.batch_size,
							        self.image_processing_tester.num_channels,
							        expected_height,
							        expected_width,
							    )				,				)




				def      __a						(					self     )				->      Any:
							# Initialize image_processor
							lowerCAmelCase_						=	self.image_processing_class(**self.image_processor_dict     )
							# create random PyTorch tensors
							lowerCAmelCase_						=	prepare_image_inputs(self.image_processing_tester				,				equal_resolution=SCREAMING_SNAKE_CASE_				,				torchify=SCREAMING_SNAKE_CASE_     )
							for image in image_inputs:
										self.assertIsInstance(SCREAMING_SNAKE_CASE_				,				torch.Tensor     )

							# Test not batched input
							lowerCAmelCase_						=	image_processor(image_inputs[0]				,				["semantic"]				,				return_tensors="pt"     ).pixel_values

							lowerCAmelCase_						=	self.image_processing_tester.get_expected_values(SCREAMING_SNAKE_CASE_     )

							self.assertEqual(
							    encoded_images.shape				,				(1, self.image_processing_tester.num_channels, expected_height, expected_width)				,				)

							# Test batched
							lowerCAmelCase_						=	self.image_processing_tester.get_expected_values(SCREAMING_SNAKE_CASE_				,				batched=SCREAMING_SNAKE_CASE_     )

							lowerCAmelCase_						=	image_processor(
							    SCREAMING_SNAKE_CASE_				,				["semantic"] * len(SCREAMING_SNAKE_CASE_     )				,				return_tensors="pt"     ).pixel_values
							self.assertEqual(
							    encoded_images.shape				,				(
							        self.image_processing_tester.batch_size,
							        self.image_processing_tester.num_channels,
							        expected_height,
							        expected_width,
							    )				,				)




				def      __a						(					self				,				_UpperCamelCase=False				,				_UpperCamelCase=False				,				_UpperCamelCase="np"     )				->      int:
							lowerCAmelCase_						=	self.image_processing_class(**self.image_processor_dict     )
							# prepare image and target
							lowerCAmelCase_						=	self.image_processing_tester.num_labels
							lowerCAmelCase_						=	None
							lowerCAmelCase_						=	None
							lowerCAmelCase_						=	prepare_image_inputs(self.image_processing_tester				,				equal_resolution=SCREAMING_SNAKE_CASE_     )
							if with_segmentation_maps:
										lowerCAmelCase_						=	num_labels
										if is_instance_map:
													lowerCAmelCase_						=	list(range(SCREAMING_SNAKE_CASE_     )     ) * 2
													lowerCAmelCase_						=	dict(enumerate(SCREAMING_SNAKE_CASE_     )     )
										lowerCAmelCase_						=	[
										    np.random.randint(0				,				high * 2				,				(img.size[1], img.size[0])     ).astype(np.uinta     ) for img in image_inputs
										]
										if segmentation_type == "pil":
													lowerCAmelCase_						=	[Image.fromarray(SCREAMING_SNAKE_CASE_     ) for annotation in annotations]

							lowerCAmelCase_						=	image_processor(
							    SCREAMING_SNAKE_CASE_				,				["semantic"] * len(SCREAMING_SNAKE_CASE_     )				,				SCREAMING_SNAKE_CASE_				,				return_tensors="pt"				,				instance_id_to_semantic_id=SCREAMING_SNAKE_CASE_				,				pad_and_return_pixel_mask=SCREAMING_SNAKE_CASE_				,				)

							return inputs




				def      __a						(					self     )				->      int:
							pass




				def      __a						(					self     )				->      Union[str, Any]:
							def common(_UpperCamelCase=False				,				_UpperCamelCase=None     ):
										lowerCAmelCase_						=	self.comm_get_image_processor_inputs(
										    with_segmentation_maps=SCREAMING_SNAKE_CASE_				,				is_instance_map=SCREAMING_SNAKE_CASE_				,				segmentation_type=SCREAMING_SNAKE_CASE_     )

										lowerCAmelCase_						=	inputs['mask_labels']
										lowerCAmelCase_						=	inputs['class_labels']
										lowerCAmelCase_						=	inputs['pixel_values']
										lowerCAmelCase_						=	inputs['text_inputs']

										# check the batch_size
										for mask_label, class_label, text_input in zip(SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_				,				SCREAMING_SNAKE_CASE_     ):
													self.assertEqual(mask_label.shape[0]				,				class_label.shape[0]     )
													# this ensure padding has happened
													self.assertEqual(mask_label.shape[1:]				,				pixel_values.shape[2:]     )
													self.assertEqual(len(SCREAMING_SNAKE_CASE_     )				,				self.image_processing_tester.num_text     )

							common()
							common(is_instance_map=SCREAMING_SNAKE_CASE_     )
							common(is_instance_map=SCREAMING_SNAKE_CASE_				,				segmentation_type="pil"     )
							common(is_instance_map=SCREAMING_SNAKE_CASE_				,				segmentation_type="pil"     )




				def      __a						(					self     )				->      Dict:
							lowerCAmelCase_						=	np.zeros((20, 50)     )
							lowerCAmelCase_						=	1
							lowerCAmelCase_						=	1
							lowerCAmelCase_						=	1

							lowerCAmelCase_						=	binary_mask_to_rle(SCREAMING_SNAKE_CASE_     )
							self.assertEqual(len(SCREAMING_SNAKE_CASE_     )				,				4     )
							self.assertEqual(rle[0]				,				21     )
							self.assertEqual(rle[1]				,				45     )




				def      __a						(					self     )				->      Union[str, Any]:
							lowerCAmelCase_						=	self.image_processing_class(
							    num_labels=self.image_processing_tester.num_classes				,				max_seq_length=77				,				task_seq_length=77				,				class_info_file="ade20k_panoptic.json"				,				num_text=self.image_processing_tester.num_text				,				repo_path="shi-labs/oneformer_demo"				,				)
							lowerCAmelCase_						=	self.image_processing_tester.get_fake_oneformer_outputs()

							lowerCAmelCase_						=	fature_extractor.post_process_semantic_segmentation(SCREAMING_SNAKE_CASE_     )

							self.assertEqual(len(SCREAMING_SNAKE_CASE_     )				,				self.image_processing_tester.batch_size     )
							self.assertEqual(
							    segmentation[0].shape				,				(
							        self.image_processing_tester.height,
							        self.image_processing_tester.width,
							    )				,				)

							lowerCAmelCase_						=	[(1, 4) for i in range(self.image_processing_tester.batch_size     )]
							lowerCAmelCase_						=	fature_extractor.post_process_semantic_segmentation(SCREAMING_SNAKE_CASE_				,				target_sizes=SCREAMING_SNAKE_CASE_     )

							self.assertEqual(segmentation[0].shape				,				target_sizes[0]     )




				def      __a						(					self     )				->      str:
							lowerCAmelCase_						=	self.image_processing_class(
							    num_labels=self.image_processing_tester.num_classes				,				max_seq_length=77				,				task_seq_length=77				,				class_info_file="ade20k_panoptic.json"				,				num_text=self.image_processing_tester.num_text				,				repo_path="shi-labs/oneformer_demo"				,				)
							lowerCAmelCase_						=	self.image_processing_tester.get_fake_oneformer_outputs()
							lowerCAmelCase_						=	image_processor.post_process_instance_segmentation(SCREAMING_SNAKE_CASE_				,				threshold=0     )

							self.assertTrue(len(SCREAMING_SNAKE_CASE_     ) == self.image_processing_tester.batch_size     )
							for el in segmentation:
										self.assertTrue("segmentation" in el     )
										self.assertTrue("segments_info" in el     )
										self.assertEqual(type(el["segments_info"]     )				,				SCREAMING_SNAKE_CASE_     )
										self.assertEqual(
										    el["segmentation"].shape				,				(self.image_processing_tester.height, self.image_processing_tester.width)     )




				def      __a						(					self     )				->      int:
							lowerCAmelCase_						=	self.image_processing_class(
							    num_labels=self.image_processing_tester.num_classes				,				max_seq_length=77				,				task_seq_length=77				,				class_info_file="ade20k_panoptic.json"				,				num_text=self.image_processing_tester.num_text				,				repo_path="shi-labs/oneformer_demo"				,				)
							lowerCAmelCase_						=	self.image_processing_tester.get_fake_oneformer_outputs()
							lowerCAmelCase_						=	image_processor.post_process_panoptic_segmentation(SCREAMING_SNAKE_CASE_				,				threshold=0     )

							self.assertTrue(len(SCREAMING_SNAKE_CASE_     ) == self.image_processing_tester.batch_size     )
							for el in segmentation:
										self.assertTrue("segmentation" in el     )
										self.assertTrue("segments_info" in el     )
										self.assertEqual(type(el["segments_info"]     )				,				SCREAMING_SNAKE_CASE_     )
										self.assertEqual(
										    el["segmentation"].shape				,				(self.image_processing_tester.height, self.image_processing_tester.width)     )








from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional

from packaging import version


if TYPE_CHECKING:
    from ... import PreTrainedTokenizer, TensorType

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast, PatchingSpec
from ...utils import is_torch_available, logging


__UpperCAmelCase          =       logging.get_logger(__name__)

__UpperCAmelCase          =       {
    '''bigscience/bloom''': '''https://huggingface.co/bigscience/bloom/resolve/main/config.json''',
    '''bigscience/bloom-560m''': '''https://huggingface.co/bigscience/bloom-560m/blob/main/config.json''',
    '''bigscience/bloom-1b1''': '''https://huggingface.co/bigscience/bloom-1b1/blob/main/config.json''',
    '''bigscience/bloom-1b7''': '''https://huggingface.co/bigscience/bloom-1b7/blob/main/config.json''',
    '''bigscience/bloom-3b''': '''https://huggingface.co/bigscience/bloom-3b/blob/main/config.json''',
    '''bigscience/bloom-7b1''': '''https://huggingface.co/bigscience/bloom-7b1/blob/main/config.json''',
}



class 				lowerCAmelCase_		(  a__							):
       UpperCAmelCase__				:					Tuple        =  "bloom"
       UpperCAmelCase__				:					List[Any]        =  ["past_key_values"]
       UpperCAmelCase__				:					str        =  {
           "num_hidden_layers": "n_layer",
           "num_attention_heads": "n_head",
       }
       def __init__(			self,			SCREAMING_SNAKE_CASE_=25_0880,			SCREAMING_SNAKE_CASE_=64,			SCREAMING_SNAKE_CASE_=2,			SCREAMING_SNAKE_CASE_=8,			SCREAMING_SNAKE_CASE_=1e-5,			SCREAMING_SNAKE_CASE_=0.02,			SCREAMING_SNAKE_CASE_=True,			SCREAMING_SNAKE_CASE_=1,			SCREAMING_SNAKE_CASE_=2,			SCREAMING_SNAKE_CASE_=False,			SCREAMING_SNAKE_CASE_=0.0,			SCREAMING_SNAKE_CASE_=0.0,			SCREAMING_SNAKE_CASE_=1,			SCREAMING_SNAKE_CASE_=False,			**SCREAMING_SNAKE_CASE_,			)     ->		Tuple:
          UpperCamelCase    :  str							=	vocab_size
          # Backward compatibility with n_embed kwarg
          UpperCamelCase    :  Optional[Any]							=	kwargs.pop('n_embed',			SCREAMING_SNAKE_CASE_       )
          UpperCamelCase    :  Union[str, Any]							=	hidden_size if n_embed is None else n_embed
          UpperCamelCase    :  Tuple							=	n_layer
          UpperCamelCase    :  Dict							=	n_head
          UpperCamelCase    :  List[Any]							=	layer_norm_epsilon
          UpperCamelCase    :  Optional[int]							=	initializer_range
          UpperCamelCase    :  int							=	use_cache
          UpperCamelCase    :  int							=	pretraining_tp
          UpperCamelCase    :  Optional[int]							=	apply_residual_connection_post_layernorm
          UpperCamelCase    :  str							=	hidden_dropout
          UpperCamelCase    :  str							=	attention_dropout

          UpperCamelCase    :  List[Any]							=	bos_token_id
          UpperCamelCase    :  Tuple							=	eos_token_id
          UpperCamelCase    :  Union[str, Any]							=	slow_but_exact

          super().__init__(bos_token_id=SCREAMING_SNAKE_CASE_,			eos_token_id=SCREAMING_SNAKE_CASE_,			**SCREAMING_SNAKE_CASE_       )






class 				lowerCAmelCase_		(  a__							):
       UpperCAmelCase__				:					Any        =  version.parse("1.12"							)
       def __init__(			self,			SCREAMING_SNAKE_CASE_,			SCREAMING_SNAKE_CASE_ = "default",			SCREAMING_SNAKE_CASE_ = None,			SCREAMING_SNAKE_CASE_ = False,			)     ->		Any:
          super().__init__(SCREAMING_SNAKE_CASE_,			task=SCREAMING_SNAKE_CASE_,			patching_specs=SCREAMING_SNAKE_CASE_,			use_past=SCREAMING_SNAKE_CASE_       )
          if not getattr(self._config,			'pad_token_id',			SCREAMING_SNAKE_CASE_       ):
             # TODO: how to do that better?
             UpperCamelCase    :  Tuple							=	0
       @property
       def 					snake_case_       (			self       )     ->		Mapping[str, Mapping[int, str]]:
          UpperCamelCase    :  str							=	OrderedDict({'input_ids': {0: 'batch', 1: 'sequence'}}       )
          if self.use_past:
             # BLOOM stores values on dynamic axis 2. For more details see: https://github.com/huggingface/transformers/pull/18344
             self.fill_with_past_key_values_(SCREAMING_SNAKE_CASE_,			direction='inputs',			inverted_values_shape=SCREAMING_SNAKE_CASE_       )
             UpperCamelCase    :  Union[str, Any]							=	{0: 'batch', 1: 'past_sequence + sequence'}
          else:
             UpperCamelCase    :  Optional[int]							=	{0: 'batch', 1: 'sequence'}

          return common_inputs
       @property
       def 					snake_case_       (			self       )     ->		int:
          return self._config.n_layer
       @property
       def 					snake_case_       (			self       )     ->		int:
          return self._config.n_head
       @property
       def 					snake_case_       (			self       )     ->		float:
          return 1e-3
       def 					snake_case_       (			self,			SCREAMING_SNAKE_CASE_,			SCREAMING_SNAKE_CASE_ = -1,			SCREAMING_SNAKE_CASE_ = -1,			SCREAMING_SNAKE_CASE_ = False,			SCREAMING_SNAKE_CASE_ = None,			)     ->		Mapping[str, Any]:
          UpperCamelCase    :  Dict							=	super(SCREAMING_SNAKE_CASE_,			self       ).generate_dummy_inputs(
              SCREAMING_SNAKE_CASE_,			batch_size=SCREAMING_SNAKE_CASE_,			seq_length=SCREAMING_SNAKE_CASE_,			is_pair=SCREAMING_SNAKE_CASE_,			framework=SCREAMING_SNAKE_CASE_       )

          # We need to order the input in the way they appears in the forward()
          UpperCamelCase    :  Any							=	OrderedDict({'input_ids': common_inputs['input_ids']}       )

          # Need to add the past_keys
          if self.use_past:
             if not is_torch_available():
                raise ValueError('Cannot generate dummy past_keys inputs without PyTorch installed.'       )
             else:
                import torch

                UpperCamelCase	,     UpperCamelCase    :  int							=	common_inputs['input_ids'].shape
                # Not using the same length for past_key_values
                UpperCamelCase    :  Any							=	seqlen + 2
                UpperCamelCase    :  Optional[int]							=	self._config.hidden_size // self.num_attention_heads
                UpperCamelCase    :  Any							=	(
                    batch * self.num_attention_heads,
                    head_dim,
                    past_key_values_length,
                )
                UpperCamelCase    :  Optional[Any]							=	(
                    batch * self.num_attention_heads,
                    past_key_values_length,
                    head_dim,
                )
                UpperCamelCase    :  List[str]							=	[
                    (torch.zeros(SCREAMING_SNAKE_CASE_       ), torch.zeros(SCREAMING_SNAKE_CASE_       )) for _ in range(self.num_layers       )
                ]

          UpperCamelCase    :  str							=	common_inputs['attention_mask']
          if self.use_past:
             UpperCamelCase    :  int							=	ordered_inputs['attention_mask'].dtype
             UpperCamelCase    :  List[Any]							=	torch.cat(
                 [ordered_inputs['attention_mask'], torch.ones(SCREAMING_SNAKE_CASE_,			SCREAMING_SNAKE_CASE_,			dtype=SCREAMING_SNAKE_CASE_       )],			dim=1       )

          return ordered_inputs






       @property
       def 					snake_case_       (			self       )     ->		int:
          return 13



