


"""simple docstring"""







from __future__ import annotations

import inspect
import unittest

import numpy as np

from transformers import SwinConfig
from transformers.testing_utils import require_tf, require_vision, slow, to_atuple
from transformers.utils import cached_property, is_tf_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
						import tensorflow as tf

						from transformers.models.swin.modeling_tf_swin import (
						    TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
						    TFSwinForImageClassification,
						    TFSwinForMaskedImageModeling,
						    TFSwinModel,
						)


if is_vision_available():
						from PIL import Image

						from transformers import AutoImageProcessor
class 							lowerCamelCase       :


							"""simple docstring"""






							def __init__(						self :     str		, lowerCamelCase_ :     Optional[Any]		, lowerCamelCase_ :     int=13		, lowerCamelCase_ :     Dict=32		, lowerCamelCase_ :     int=2		, lowerCamelCase_ :     Union[str, Any]=3		, lowerCamelCase_ :     Tuple=16		, lowerCamelCase_ :     Optional[Any]=[1, 2, 1]		, lowerCamelCase_ :     str=[2, 2, 4]		, lowerCamelCase_ :     Any=2		, lowerCamelCase_ :     int=2.0		, lowerCamelCase_ :     List[str]=True		, lowerCamelCase_ :     Any=0.0		, lowerCamelCase_ :     Optional[Any]=0.0		, lowerCamelCase_ :     Optional[int]=0.1		, lowerCamelCase_ :     Any="gelu"		, lowerCamelCase_ :     List[str]=False		, lowerCamelCase_ :     Tuple=True		, lowerCamelCase_ :     str=0.02		, lowerCamelCase_ :     List[str]=1E-5		, lowerCamelCase_ :     Optional[Any]=True		, lowerCamelCase_ :     Optional[Any]=None		, lowerCamelCase_ :     int=True		, lowerCamelCase_ :     List[Any]=10		, lowerCamelCase_ :     List[str]=8		, ):
													UpperCAmelCase__		=    parent
													UpperCAmelCase__		=    batch_size
													UpperCAmelCase__		=    image_size
													UpperCAmelCase__		=    patch_size
													UpperCAmelCase__		=    num_channels
													UpperCAmelCase__		=    embed_dim
													UpperCAmelCase__		=    depths
													UpperCAmelCase__		=    num_heads
													UpperCAmelCase__		=    window_size
													UpperCAmelCase__		=    mlp_ratio
													UpperCAmelCase__		=    qkv_bias
													UpperCAmelCase__		=    hidden_dropout_prob
													UpperCAmelCase__		=    attention_probs_dropout_prob
													UpperCAmelCase__		=    drop_path_rate
													UpperCAmelCase__		=    hidden_act
													UpperCAmelCase__		=    use_absolute_embeddings
													UpperCAmelCase__		=    patch_norm
													UpperCAmelCase__		=    layer_norm_eps
													UpperCAmelCase__		=    initializer_range
													UpperCAmelCase__		=    is_training
													UpperCAmelCase__		=    scope
													UpperCAmelCase__		=    use_labels
													UpperCAmelCase__		=    type_sequence_label_size
													UpperCAmelCase__		=    encoder_stride






							def 					lowerCAmelCase     (						self :     int				):
													UpperCAmelCase__		=    floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]				)

													UpperCAmelCase__		=    None
													if self.use_labels:
																			UpperCAmelCase__		=    ids_tensor([self.batch_size]		, self.type_sequence_label_size				)

													UpperCAmelCase__		=    self.get_config()

													return config, pixel_values, labels






							def 					lowerCAmelCase     (						self :     Tuple				):
													return SwinConfig(
													    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		, encoder_stride=self.encoder_stride		, )






							def 					lowerCAmelCase     (						self :     Optional[int]		, lowerCamelCase_ :     Dict		, lowerCamelCase_ :     Optional[int]		, lowerCamelCase_ :     List[str]				):
													UpperCAmelCase__		=    TFSwinModel(config=lowerCamelCase_				)
													UpperCAmelCase__		=    model(lowerCamelCase_				)

													UpperCAmelCase__		=    ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths				) - 1))
													UpperCAmelCase__		=    int(config.embed_dim * 2 ** (len(config.depths				) - 1)				)

													self.parent.assertEqual(result.last_hidden_state.shape		, (self.batch_size, expected_seq_len, expected_dim)				)






							def 					lowerCAmelCase     (						self :     Dict		, lowerCamelCase_ :     str		, lowerCamelCase_ :     Optional[Any]		, lowerCamelCase_ :     Optional[Any]				):
													UpperCAmelCase__		=    TFSwinForMaskedImageModeling(config=lowerCamelCase_				)
													UpperCAmelCase__		=    model(lowerCamelCase_				)
													self.parent.assertEqual(
													    result.logits.shape		, (self.batch_size, self.num_channels, self.image_size, self.image_size)				)

													# test greyscale images
													UpperCAmelCase__		=    1
													UpperCAmelCase__		=    TFSwinForMaskedImageModeling(lowerCamelCase_				)

													UpperCAmelCase__		=    floats_tensor([self.batch_size, 1, self.image_size, self.image_size]				)
													UpperCAmelCase__		=    model(lowerCamelCase_				)
													self.parent.assertEqual(result.logits.shape		, (self.batch_size, 1, self.image_size, self.image_size)				)






							def 					lowerCAmelCase     (						self :     int		, lowerCamelCase_ :     List[Any]		, lowerCamelCase_ :     List[Any]		, lowerCamelCase_ :     int				):
													UpperCAmelCase__		=    self.type_sequence_label_size
													UpperCAmelCase__		=    TFSwinForImageClassification(lowerCamelCase_				)
													UpperCAmelCase__		=    model(lowerCamelCase_		, labels=lowerCamelCase_				)
													self.parent.assertEqual(result.logits.shape		, (self.batch_size, self.type_sequence_label_size)				)

													# test greyscale images
													UpperCAmelCase__		=    1
													UpperCAmelCase__		=    TFSwinForImageClassification(lowerCamelCase_				)
													UpperCAmelCase__		=    floats_tensor([self.batch_size, 1, self.image_size, self.image_size]				)
													UpperCAmelCase__		=    model(lowerCamelCase_				)
													self.parent.assertEqual(result.logits.shape		, (self.batch_size, self.type_sequence_label_size)				)






							def 					lowerCAmelCase     (						self :     int				):
													UpperCAmelCase__		=    self.prepare_config_and_inputs()
													UpperCAmelCase__	,				UpperCAmelCase__	,				UpperCAmelCase__		=    config_and_inputs
													UpperCAmelCase__		=    {'''pixel_values''': pixel_values}
													return config, inputs_dict




@require_tf
class 							lowerCamelCase       (			__SCREAMING_SNAKE_CASE				,					__SCREAMING_SNAKE_CASE				,					unittest.TestCase ):


							"""simple docstring"""
							SCREAMING_SNAKE_CASE										=      (
							    (
							        TFSwinModel,
							        TFSwinForImageClassification,
							        TFSwinForMaskedImageModeling,
							    )
							    if is_tf_available()
							    else ()
							)
							SCREAMING_SNAKE_CASE										=      (
							    {"""feature-extraction""": TFSwinModel, """image-classification""": TFSwinForImageClassification}
							    if is_tf_available()
							    else {}
							)

							SCREAMING_SNAKE_CASE										=      False
							SCREAMING_SNAKE_CASE										=      False
							SCREAMING_SNAKE_CASE										=      False
							SCREAMING_SNAKE_CASE										=      False






							def 					lowerCAmelCase     (						self :     List[Any]				):
													UpperCAmelCase__		=    TFSwinModelTester(self				)
													UpperCAmelCase__		=    ConfigTester(self		, config_class=lowerCamelCase_		, embed_dim=37				)






							def 					lowerCAmelCase     (						self :     Union[str, Any]				):
													self.create_and_test_config_common_properties()
													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 :     List[Any]				):
													return






							def 					lowerCAmelCase     (						self :     str				):
													UpperCAmelCase__		=    self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_model(*lowerCamelCase_				)






							def 					lowerCAmelCase     (						self :     Any				):
													UpperCAmelCase__		=    self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_masked_image_modeling(*lowerCamelCase_				)






							def 					lowerCAmelCase     (						self :     Any				):
													UpperCAmelCase__		=    self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_image_classification(*lowerCamelCase_				)






							@unittest.skip(reason='''Swin does not use inputs_embeds'''				)
							def 					lowerCAmelCase     (						self :     str				):
													pass






							def 					lowerCAmelCase     (						self :     Any				):
													UpperCAmelCase__	,				UpperCAmelCase__		=    self.model_tester.prepare_config_and_inputs_for_common()

													for model_class in self.all_model_classes:
																			UpperCAmelCase__		=    model_class(lowerCamelCase_				)
																			self.assertIsInstance(model.get_input_embeddings()		, tf.keras.layers.Layer				)
																			UpperCAmelCase__		=    model.get_output_embeddings()
																			self.assertTrue(x is None or isinstance(lowerCamelCase_		, tf.keras.layers.Dense				)				)






							def 					lowerCAmelCase     (						self :     str				):
													UpperCAmelCase__	,				UpperCAmelCase__		=    self.model_tester.prepare_config_and_inputs_for_common()

													for model_class in self.all_model_classes:
																			UpperCAmelCase__		=    model_class(lowerCamelCase_				)
																			UpperCAmelCase__		=    inspect.signature(model.call				)
																			# signature.parameters is an OrderedDict => so arg_names order is deterministic
																			UpperCAmelCase__		=    [*signature.parameters.keys()]

																			UpperCAmelCase__		=    ['''pixel_values''']
																			self.assertListEqual(arg_names[:1]		, lowerCamelCase_				)






							def 					lowerCAmelCase     (						self :     List[Any]				):
													UpperCAmelCase__	,				UpperCAmelCase__		=    self.model_tester.prepare_config_and_inputs_for_common()
													UpperCAmelCase__		=    True

													for model_class in self.all_model_classes:
																			UpperCAmelCase__		=    True
																			UpperCAmelCase__		=    False
																			UpperCAmelCase__		=    True
																			UpperCAmelCase__		=    model_class(lowerCamelCase_				)
																			UpperCAmelCase__		=    model(**self._prepare_for_class(lowerCamelCase_		, lowerCamelCase_				)				)
																			UpperCAmelCase__		=    outputs.attentions
																			UpperCAmelCase__		=    len(self.model_tester.depths				)
																			self.assertEqual(len(lowerCamelCase_				)		, lowerCamelCase_				)

																			# check that output_attentions also work using config
																			del inputs_dict["output_attentions"]
																			UpperCAmelCase__		=    True
																			UpperCAmelCase__		=    config.window_size**2
																			UpperCAmelCase__		=    model_class(lowerCamelCase_				)
																			UpperCAmelCase__		=    model(**self._prepare_for_class(lowerCamelCase_		, lowerCamelCase_				)				)
																			UpperCAmelCase__		=    outputs.attentions
																			self.assertEqual(len(lowerCamelCase_				)		, lowerCamelCase_				)

																			self.assertListEqual(
																			    list(attentions[0].shape[-3:]				)		, [self.model_tester.num_heads[0], window_size_squared, window_size_squared]		, )
																			UpperCAmelCase__		=    len(lowerCamelCase_				)

																			# Check attention is always last and order is fine
																			UpperCAmelCase__		=    True
																			UpperCAmelCase__		=    True
																			UpperCAmelCase__		=    model_class(lowerCamelCase_				)
																			UpperCAmelCase__		=    model(**self._prepare_for_class(lowerCamelCase_		, lowerCamelCase_				)				)

																			if hasattr(self.model_tester		, '''num_hidden_states_types'''				):
																									UpperCAmelCase__		=    self.model_tester.num_hidden_states_types
																			else:
																									# also another +1 for reshaped_hidden_states
																									UpperCAmelCase__		=    2
																			self.assertEqual(out_len + added_hidden_states		, len(lowerCamelCase_				)				)

																			UpperCAmelCase__		=    outputs.attentions

																			self.assertEqual(len(lowerCamelCase_				)		, lowerCamelCase_				)

																			self.assertListEqual(
																			    list(self_attentions[0].shape[-3:]				)		, [self.model_tester.num_heads[0], window_size_squared, window_size_squared]		, )






							def 					lowerCAmelCase     (						self :     Union[str, Any]		, lowerCamelCase_ :     Dict		, lowerCamelCase_ :     List[str]		, lowerCamelCase_ :     Dict		, lowerCamelCase_ :     Dict				):
													UpperCAmelCase__		=    model_class(lowerCamelCase_				)
													UpperCAmelCase__		=    model(**self._prepare_for_class(lowerCamelCase_		, lowerCamelCase_				)				)
													UpperCAmelCase__		=    outputs.hidden_states

													UpperCAmelCase__		=    getattr(
													    self.model_tester		, '''expected_num_hidden_layers'''		, len(self.model_tester.depths				) + 1				)
													self.assertEqual(len(lowerCamelCase_				)		, lowerCamelCase_				)

													# Swin has a different seq_length
													UpperCAmelCase__		=    to_atuple(config.patch_size				)

													UpperCAmelCase__		=    (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

													self.assertListEqual(
													    list(hidden_states[0].shape[-2:]				)		, [num_patches, self.model_tester.embed_dim]		, )

													UpperCAmelCase__		=    outputs.reshaped_hidden_states
													self.assertEqual(len(lowerCamelCase_				)		, lowerCamelCase_				)

													UpperCAmelCase__	,				UpperCAmelCase__	,				UpperCAmelCase__	,				UpperCAmelCase__		=    reshaped_hidden_states[0].shape

													UpperCAmelCase__		=    tf.reshape(reshaped_hidden_states[0]		, (batch_size, num_channels, height * width)				)
													UpperCAmelCase__		=    tf.transpose(lowerCamelCase_		, (0, 2, 1)				)

													self.assertListEqual(
													    list(reshaped_hidden_states.shape[-2:]				)		, [num_patches, self.model_tester.embed_dim]		, )






							def 					lowerCAmelCase     (						self :     Union[str, Any]				):
													UpperCAmelCase__	,				UpperCAmelCase__		=    self.model_tester.prepare_config_and_inputs_for_common()

													UpperCAmelCase__		=    to_atuple(self.model_tester.image_size				)

													for model_class in self.all_model_classes:
																			UpperCAmelCase__		=    True
																			self.check_hidden_states_output(lowerCamelCase_		, lowerCamelCase_		, lowerCamelCase_		, lowerCamelCase_				)

																			# check that output_hidden_states also work using config
																			del inputs_dict["output_hidden_states"]
																			UpperCAmelCase__		=    True

																			self.check_hidden_states_output(lowerCamelCase_		, lowerCamelCase_		, lowerCamelCase_		, lowerCamelCase_				)






							def 					lowerCAmelCase     (						self :     str				):
													UpperCAmelCase__	,				UpperCAmelCase__		=    self.model_tester.prepare_config_and_inputs_for_common()
													UpperCAmelCase__		=    3

													UpperCAmelCase__		=    to_atuple(self.model_tester.image_size				)
													UpperCAmelCase__		=    to_atuple(config.patch_size				)

													UpperCAmelCase__		=    image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
													UpperCAmelCase__		=    image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

													for model_class in self.all_model_classes:
																			UpperCAmelCase__		=    True
																			self.check_hidden_states_output(lowerCamelCase_		, lowerCamelCase_		, lowerCamelCase_		, (padded_height, padded_width)				)

																			# check that output_hidden_states also work using config
																			del inputs_dict["output_hidden_states"]
																			UpperCAmelCase__		=    True
																			self.check_hidden_states_output(lowerCamelCase_		, lowerCamelCase_		, lowerCamelCase_		, (padded_height, padded_width)				)






							@slow
							def 					lowerCAmelCase     (						self :     Dict				):
													for model_name in TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																			UpperCAmelCase__		=    TFSwinModel.from_pretrained(lowerCamelCase_				)
																			self.assertIsNotNone(lowerCamelCase_				)




@require_vision
@require_tf
class 							lowerCamelCase       (			unittest.TestCase ):


							"""simple docstring"""






							@cached_property
							def 					lowerCAmelCase     (						self :     Optional[int]				):
													return (
													    AutoImageProcessor.from_pretrained('''microsoft/swin-tiny-patch4-window7-224'''				)
													    if is_vision_available()
													    else None
													)






							@slow
							def 					lowerCAmelCase     (						self :     str				):
													UpperCAmelCase__		=    TFSwinForImageClassification.from_pretrained('''microsoft/swin-tiny-patch4-window7-224'''				)
													UpperCAmelCase__		=    self.default_image_processor

													UpperCAmelCase__		=    Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''				)
													UpperCAmelCase__		=    image_processor(images=lowerCamelCase_		, return_tensors='''tf'''				)

													# forward pass
													UpperCAmelCase__		=    model(lowerCamelCase_				)

													# verify the logits
													UpperCAmelCase__		=    tf.TensorShape((1, 1000)				)
													self.assertEqual(outputs.logits.shape		, lowerCamelCase_				)
													UpperCAmelCase__		=    tf.constant([-0.0948, -0.6454, -0.0921]				)
													self.assertTrue(np.allclose(outputs.logits[0, :3]		, lowerCamelCase_		, atol=1E-4				)				)



"""simple docstring"""







from __future__ import annotations

from collections.abc import Callable
from typing import Generic, TypeVar

__a			 =   TypeVar("T")
__a			 =   TypeVar("U")
class 							lowerCamelCase       (			Generic[T, U] ):


							"""simple docstring"""






							def __init__(						self :     str		, lowerCamelCase_ :     T | None		, lowerCamelCase_ :     U | None				):
													UpperCAmelCase__		=    key
													UpperCAmelCase__		=    val
													UpperCAmelCase__		=    0
													UpperCAmelCase__		=    None
													UpperCAmelCase__		=    None






							def __repr__(						self :     Tuple				):
													return "Node: key: {}, val: {}, freq: {}, has next: {}, has prev: {}".format(
													    self.key		, self.val		, self.freq		, self.next is not None		, self.prev is not None				)




class 							lowerCamelCase       (			Generic[T, U] ):


							"""simple docstring"""






							def __init__(						self :     List[str]				):
													UpperCAmelCase__		=    DoubleLinkedListNode(lowerCamelCase_		, lowerCamelCase_				)
													UpperCAmelCase__		=    DoubleLinkedListNode(lowerCamelCase_		, lowerCamelCase_				)
													UpperCAmelCase__	,				UpperCAmelCase__		=    self.rear, self.head






							def __repr__(						self :     int				):
													UpperCAmelCase__		=    ['''DoubleLinkedList''']
													UpperCAmelCase__		=    self.head
													while node.next is not None:
																			rep.append(str(lowerCamelCase_				)				)
																			UpperCAmelCase__		=    node.next
													rep.append(str(self.rear				)				)
													return ",\n    ".join(lowerCamelCase_				)






							def 					lowerCAmelCase     (						self :     List[Any]		, lowerCamelCase_ :     DoubleLinkedListNode[T, U]				):
													UpperCAmelCase__		=    self.rear.prev

													# All nodes other than self.head are guaranteed to have non-None previous
													assert previous is not None

													UpperCAmelCase__		=    node
													UpperCAmelCase__		=    previous
													UpperCAmelCase__		=    node
													UpperCAmelCase__		=    self.rear
													node.freq += 1
													self._position_node(lowerCamelCase_				)






							def 					lowerCAmelCase     (						self :     Optional[Any]		, lowerCamelCase_ :     DoubleLinkedListNode[T, U]				):

													while node.prev is not None and node.prev.freq > node.freq:
																			# swap node with previous node
																			UpperCAmelCase__		=    node.prev

																			UpperCAmelCase__		=    previous_node.prev
																			UpperCAmelCase__		=    node.prev
																			UpperCAmelCase__		=    previous_node
																			UpperCAmelCase__		=    node






							def 					lowerCAmelCase     (						self :     Union[str, Any]		, lowerCamelCase_ :     DoubleLinkedListNode[T, U]				):

													if node.prev is None or node.next is None:
																			return None

													UpperCAmelCase__		=    node.next
													UpperCAmelCase__		=    node.prev
													UpperCAmelCase__		=    None
													UpperCAmelCase__		=    None
													return node




class 							lowerCamelCase       (			Generic[T, U] ):


							"""simple docstring"""
							SCREAMING_SNAKE_CASE										=      {}






							def __init__(						self :     str		, lowerCamelCase_ :     int				):
													UpperCAmelCase__		=    DoubleLinkedList()
													UpperCAmelCase__		=    capacity
													UpperCAmelCase__		=    0
													UpperCAmelCase__		=    0
													UpperCAmelCase__		=    0
													UpperCAmelCase__		=    {}






							def __repr__(						self :     Tuple				):
													return (
													    f"""CacheInfo(hits={self.hits}, misses={self.miss}, """
													    f"""capacity={self.capacity}, current_size={self.num_keys})"""
													)






							def __contains__(						self :     Optional[Any]		, lowerCamelCase_ :     T				):
													return key in self.cache






							def 					lowerCAmelCase     (						self :     Any		, lowerCamelCase_ :     T				):

													if key in self.cache:
																			self.hits += 1
																			UpperCAmelCase__		=    self.cache[key]
																			UpperCAmelCase__		=    self.list.remove(self.cache[key]				)
																			assert node == value_node

																			# node is guaranteed not None because it is in self.cache
																			assert node is not None
																			self.list.add(lowerCamelCase_				)
																			return node.val
													self.miss += 1
													return None






							def 					lowerCAmelCase     (						self :     Tuple		, lowerCamelCase_ :     T		, lowerCamelCase_ :     U				):

													if key not in self.cache:
																			if self.num_keys >= self.capacity:
																									# delete first node when over capacity
																									UpperCAmelCase__		=    self.list.head.next

																									# guaranteed to have a non-None first node when num_keys > 0
																									# explain to type checker via assertions
																									assert first_node is not None
																									assert first_node.key is not None
																									assert self.list.remove(lowerCamelCase_				) is not None
																									# first_node guaranteed to be in list

																									del self.cache[first_node.key]
																									self.num_keys -= 1
																			UpperCAmelCase__		=    DoubleLinkedListNode(lowerCamelCase_		, lowerCamelCase_				)
																			self.list.add(self.cache[key]				)
																			self.num_keys += 1

													else:
																			UpperCAmelCase__		=    self.list.remove(self.cache[key]				)
																			assert node is not None  # node guaranteed to be in list
																			UpperCAmelCase__		=    value
																			self.list.add(lowerCamelCase_				)






							@classmethod
							def 					lowerCAmelCase     (						cls :     type[LFUCache[T, U]]		, lowerCamelCase_ :     int = 128				):

													def cache_decorator_inner(lowerCamelCase_ :     Callable[[T], U]				) -> Callable[..., U]:
																			def cache_decorator_wrapper(*lowerCamelCase_ :     T				) -> U:
																									if func not in cls.decorator_function_to_instance_map:
																															UpperCAmelCase__		=    LFUCache(lowerCamelCase_				)

																									UpperCAmelCase__		=    cls.decorator_function_to_instance_map[func].get(args[0]				)
																									if result is None:
																															UpperCAmelCase__		=    func(*lowerCamelCase_				)
																															cls.decorator_function_to_instance_map[func].put(args[0]		, lowerCamelCase_				)
																									return result

																			def cache_info() -> LFUCache[T, U]:
																									return cls.decorator_function_to_instance_map[func]

																			setattr(lowerCamelCase_		, '''cache_info'''		, lowerCamelCase_				)  # noqa: B010

																			return cache_decorator_wrapper

													return cache_decorator_inner


if __name__ == "__main__":
						import doctest

						doctest.testmod()