


import collections.abc
from typing import Optional, Tuple, Union

import torch
import torch.utils.checkpoint
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import PreTrainedModel
from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from .configuration_poolformer import PoolFormerConfig


__lowerCAmelCase	: List[str]  				=logging.get_logger(__name__)

# General docstring
__lowerCAmelCase	: int  				='PoolFormerConfig'

# Base docstring
__lowerCAmelCase	: Tuple  				='sail/poolformer_s12'
__lowerCAmelCase	: str  				=[1, 5_1_2, 7, 7]

# Image classification docstring
__lowerCAmelCase	: Any  				='sail/poolformer_s12'
__lowerCAmelCase	: Dict  				='tabby, tabby cat'

__lowerCAmelCase	: int  				=[
    'sail/poolformer_s12',
    # See all PoolFormer models at https://huggingface.co/models?filter=poolformer
]


def        _UpperCamelCase							(      lowercase__    ,       lowercase__ = 0.0    ,       lowercase__ = False      ):
						if drop_prob == 0.0 or not training:
												return input
						__SCREAMING_SNAKE_CASE						:     Any					=		1 - drop_prob
						__SCREAMING_SNAKE_CASE						:     Tuple					=		(input.shape[0],) + (1,) * (input.ndim - 1)  # work with diff dim tensors, not just 2D ConvNets
						__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		keep_prob + torch.rand(lowercase__    ,       dtype=input.dtype    ,       device=input.device      )
						random_tensor.floor_()  # binarize
						__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		input.div(lowercase__      ) * random_tensor
						return output
class        _lowercase      (			nn.Module       ):






				'''simple docstring'''



				def __init__(       self			:Any			,			lowerCAmelCase__			:Optional[float] = None	)		->			None:
										super().__init__()
										__SCREAMING_SNAKE_CASE						:     int					=		drop_prob


				def 		__magic_name__(       self			:Optional[int]			,			lowerCAmelCase__			:torch.Tensor	)		->			torch.Tensor:
										return drop_path(lowerCAmelCase__			,			self.drop_prob			,			self.training	)



				def 		__magic_name__(       self			:Any	)		->			str:
										return "p={}".format(self.drop_prob	)




class        _lowercase      (			nn.Module       ):






				'''simple docstring'''



				def __init__(       self			:str			,			lowerCAmelCase__			:List[str]			,			lowerCAmelCase__			:Optional[int]			,			lowerCAmelCase__			:Tuple			,			lowerCAmelCase__			:Dict			,			lowerCAmelCase__			:List[str]			,			lowerCAmelCase__			:Dict=None	)		->			Any:
										super().__init__()
										__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		patch_size if isinstance(lowerCAmelCase__			,			collections.abc.Iterable	) else (patch_size, patch_size)
										__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		stride if isinstance(lowerCAmelCase__			,			collections.abc.Iterable	) else (stride, stride)
										__SCREAMING_SNAKE_CASE						:     Any					=		padding if isinstance(lowerCAmelCase__			,			collections.abc.Iterable	) else (padding, padding)

										__SCREAMING_SNAKE_CASE						:     Any					=		nn.Convad(lowerCAmelCase__			,			lowerCAmelCase__			,			kernel_size=lowerCAmelCase__			,			stride=lowerCAmelCase__			,			padding=lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		norm_layer(lowerCAmelCase__	) if norm_layer else nn.Identity()



				def 		__magic_name__(       self			:Any			,			lowerCAmelCase__			:str	)		->			Union[str, Any]:
										__SCREAMING_SNAKE_CASE						:     List[str]					=		self.projection(lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     Dict					=		self.norm(lowerCAmelCase__	)
										return embeddings




class        _lowercase      (			nn.GroupNorm       ):






				'''simple docstring'''



				def __init__(       self			:Any			,			lowerCAmelCase__			:List[str]			,			**lowerCAmelCase__			:Optional[int]	)		->			Any:
										super().__init__(1			,			lowerCAmelCase__			,			**lowerCAmelCase__	)




class        _lowercase      (			nn.Module       ):






				'''simple docstring'''



				def __init__(       self			:Dict			,			lowerCAmelCase__			:Dict	)		->			str:
										super().__init__()
										__SCREAMING_SNAKE_CASE						:     List[str]					=		nn.AvgPoolad(lowerCAmelCase__			,			stride=1			,			padding=pool_size // 2			,			count_include_pad=lowerCAmelCase__	)



				def 		__magic_name__(       self			:Dict			,			lowerCAmelCase__			:Tuple	)		->			str:
										return self.pool(lowerCAmelCase__	) - hidden_states




class        _lowercase      (			nn.Module       ):






				'''simple docstring'''



				def __init__(       self			:List[Any]			,			lowerCAmelCase__			:Optional[Any]			,			lowerCAmelCase__			:str			,			lowerCAmelCase__			:Union[str, Any]			,			lowerCAmelCase__			:List[Any]	)		->			List[str]:
										super().__init__()
										__SCREAMING_SNAKE_CASE						:     List[str]					=		nn.Convad(lowerCAmelCase__			,			lowerCAmelCase__			,			1	)
										__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		nn.Convad(lowerCAmelCase__			,			lowerCAmelCase__			,			1	)
										__SCREAMING_SNAKE_CASE						:     Dict					=		PoolFormerDropPath(lowerCAmelCase__	)
										if isinstance(config.hidden_act			,			lowerCAmelCase__	):
																__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		ACTaFN[config.hidden_act]
										else:
																__SCREAMING_SNAKE_CASE						:     Optional[int]					=		config.hidden_act



				def 		__magic_name__(       self			:Any			,			lowerCAmelCase__			:Dict	)		->			Dict:
										__SCREAMING_SNAKE_CASE						:     Optional[int]					=		self.conva(lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     int					=		self.act_fn(lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		self.drop(lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		self.conva(lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		self.drop(lowerCAmelCase__	)

										return hidden_states




class        _lowercase      (			nn.Module       ):






				'''simple docstring'''



				def __init__(       self			:int			,			lowerCAmelCase__			:List[Any]			,			lowerCAmelCase__			:str			,			lowerCAmelCase__			:Union[str, Any]			,			lowerCAmelCase__			:Optional[int]			,			lowerCAmelCase__			:List[Any]			,			lowerCAmelCase__			:List[str]	)		->			Any:
										super().__init__()
										__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		PoolFormerPooling(lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     List[str]					=		PoolFormerOutput(lowerCAmelCase__			,			lowerCAmelCase__			,			lowerCAmelCase__			,			lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		PoolFormerGroupNorm(lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     List[str]					=		PoolFormerGroupNorm(lowerCAmelCase__	)

										# Useful for training neural nets
										__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		PoolFormerDropPath(lowerCAmelCase__	) if drop_path > 0.0 else nn.Identity()
										__SCREAMING_SNAKE_CASE						:     int					=		config.use_layer_scale
										if config.use_layer_scale:
																__SCREAMING_SNAKE_CASE						:     List[str]					=		nn.Parameter(
																    config.layer_scale_init_value * torch.ones((lowerCAmelCase__)	)			,			requires_grad=lowerCAmelCase__	)
																__SCREAMING_SNAKE_CASE						:     str					=		nn.Parameter(
																    config.layer_scale_init_value * torch.ones((lowerCAmelCase__)	)			,			requires_grad=lowerCAmelCase__	)



				def 		__magic_name__(       self			:List[str]			,			lowerCAmelCase__			:Optional[int]	)		->			Optional[Any]:
										if self.use_layer_scale:
																__SCREAMING_SNAKE_CASE						:     int					=		self.pooling(self.before_norm(lowerCAmelCase__	)	)
																__SCREAMING_SNAKE_CASE						:     Dict					=		self.layer_scale_a.unsqueeze(-1	).unsqueeze(-1	) * pooling_output
																# First residual connection
																__SCREAMING_SNAKE_CASE						:     Any					=		hidden_states + self.drop_path(lowerCAmelCase__	)
																__SCREAMING_SNAKE_CASE						:     int					=		()

																__SCREAMING_SNAKE_CASE						:     Dict					=		self.output(self.after_norm(lowerCAmelCase__	)	)
																__SCREAMING_SNAKE_CASE						:     Any					=		self.layer_scale_a.unsqueeze(-1	).unsqueeze(-1	) * layer_output
																# Second residual connection
																__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		hidden_states + self.drop_path(lowerCAmelCase__	)

																__SCREAMING_SNAKE_CASE						:     List[Any]					=		(output,) + outputs
																return outputs

										else:
																__SCREAMING_SNAKE_CASE						:     Tuple					=		self.drop_path(self.pooling(self.before_norm(lowerCAmelCase__	)	)	)
																# First residual connection
																__SCREAMING_SNAKE_CASE						:     Dict					=		pooling_output + hidden_states
																__SCREAMING_SNAKE_CASE						:     List[Any]					=		()

																# Second residual connection inside the PoolFormerOutput block
																__SCREAMING_SNAKE_CASE						:     int					=		self.drop_path(self.output(self.after_norm(lowerCAmelCase__	)	)	)
																__SCREAMING_SNAKE_CASE						:     str					=		hidden_states + layer_output

																__SCREAMING_SNAKE_CASE						:     str					=		(output,) + outputs
																return outputs




class        _lowercase      (			nn.Module       ):






				'''simple docstring'''



				def __init__(       self			:Union[str, Any]			,			lowerCAmelCase__			:Dict	)		->			Optional[int]:
										super().__init__()
										__SCREAMING_SNAKE_CASE						:     Optional[int]					=		config
										# stochastic depth decay rule
										__SCREAMING_SNAKE_CASE						:     List[str]					=		[x.item() for x in torch.linspace(0			,			config.drop_path_rate			,			sum(config.depths	)	)]

										# patch embeddings
										__SCREAMING_SNAKE_CASE						:     Dict					=		[]
										for i in range(config.num_encoder_blocks	):
																embeddings.append(
																    PoolFormerEmbeddings(
																        patch_size=config.patch_sizes[i]			,			stride=config.strides[i]			,			padding=config.padding[i]			,			num_channels=config.num_channels if i == 0 else config.hidden_sizes[i - 1]			,			hidden_size=config.hidden_sizes[i]			,			)	)
										__SCREAMING_SNAKE_CASE						:     List[Any]					=		nn.ModuleList(lowerCAmelCase__	)

										# Transformer blocks
										__SCREAMING_SNAKE_CASE						:     Any					=		[]
										__SCREAMING_SNAKE_CASE						:     Any					=		0
										for i in range(config.num_encoder_blocks	):
																# each block consists of layers
																__SCREAMING_SNAKE_CASE						:     int					=		[]
																if i != 0:
																						cur += config.depths[i - 1]
																for j in range(config.depths[i]	):
																						layers.append(
																						    PoolFormerLayer(
																						        lowerCAmelCase__			,			num_channels=config.hidden_sizes[i]			,			pool_size=config.pool_size			,			hidden_size=config.hidden_sizes[i]			,			intermediate_size=int(config.hidden_sizes[i] * config.mlp_ratio	)			,			drop_path=dpr[cur + j]			,			)	)
																blocks.append(nn.ModuleList(lowerCAmelCase__	)	)

										__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		nn.ModuleList(lowerCAmelCase__	)



				def 		__magic_name__(       self			:Union[str, Any]			,			lowerCAmelCase__			:str			,			lowerCAmelCase__			:Dict=False			,			lowerCAmelCase__			:str=True	)		->			Any:
										__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		() if output_hidden_states else None

										__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		pixel_values
										for idx, layers in enumerate(zip(self.patch_embeddings			,			self.block	)	):
																__SCREAMING_SNAKE_CASE			,			__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		layers
																# Get patch embeddings from hidden_states
																__SCREAMING_SNAKE_CASE						:     Dict					=		embedding_layer(lowerCAmelCase__	)
																# Send the embeddings through the blocks
																for _, blk in enumerate(lowerCAmelCase__	):
																						__SCREAMING_SNAKE_CASE						:     str					=		blk(lowerCAmelCase__	)
																						__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		layer_outputs[0]

																if output_hidden_states:
																						__SCREAMING_SNAKE_CASE						:     Any					=		all_hidden_states + (hidden_states,)

										if not return_dict:
																return tuple(v for v in [hidden_states, all_hidden_states] if v is not None	)

										return BaseModelOutputWithNoAttention(last_hidden_state=lowerCAmelCase__			,			hidden_states=lowerCAmelCase__	)




class        _lowercase      (			A__       ):






				'''simple docstring'''



				SCREAMING_SNAKE_CASE__				:			Optional[int]						=		PoolFormerConfig
				SCREAMING_SNAKE_CASE__				:			Optional[int]						=		'''poolformer'''
				SCREAMING_SNAKE_CASE__				:			Any						=		'''pixel_values'''
				SCREAMING_SNAKE_CASE__				:			Tuple						=		True


				def 		__magic_name__(       self			:Optional[int]			,			lowerCAmelCase__			:int	)		->			Optional[int]:
										if isinstance(lowerCAmelCase__			,			(nn.Linear, nn.Convad)	):
																module.weight.data.normal_(mean=0.0			,			std=self.config.initializer_range	)
																if module.bias is not None:
																						module.bias.data.zero_()
										elif isinstance(lowerCAmelCase__			,			nn.LayerNorm	):
																module.bias.data.zero_()
																module.weight.data.fill_(1.0	)



				def 		__magic_name__(       self			:Optional[int]			,			lowerCAmelCase__			:Dict			,			lowerCAmelCase__			:Union[str, Any]=False	)		->			str:
										if isinstance(lowerCAmelCase__			,			lowerCAmelCase__	):
																__SCREAMING_SNAKE_CASE						:     Tuple					=		value




__lowerCAmelCase	: Optional[int]  				=r'\n    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use\n    it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and\n    behavior.\n\n    Parameters:\n        config ([`PoolFormerConfig`]): Model configuration class with all the parameters of the model.\n            Initializing with a config file does not load the weights associated with the model, only the\n            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.\n'

__lowerCAmelCase	: Dict  				=r'\n    Args:\n        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):\n            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See\n            [`PoolFormerImageProcessor.__call__`] for details.\n'
@add_start_docstrings(
    '''The bare PoolFormer Model transformer outputting raw hidden-states without any specific head on top.'''						,			A__						,			)
class        _lowercase      (			A__       ):






				'''simple docstring'''



				def __init__(       self			:List[str]			,			lowerCAmelCase__			:List[str]	)		->			str:
										super().__init__(lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		config

										__SCREAMING_SNAKE_CASE						:     Dict					=		PoolFormerEncoder(lowerCAmelCase__	)

										# Initialize weights and apply final processing
										self.post_init()


				def 		__magic_name__(       self			:Dict	)		->			int:
										return self.embeddings.patch_embeddings



				@add_start_docstrings_to_model_forward(lowerCAmelCase__	)
				@add_code_sample_docstrings(
				    checkpoint=_CHECKPOINT_FOR_DOC			,			output_type=lowerCAmelCase__			,			config_class=_CONFIG_FOR_DOC			,			modality='''vision'''			,			expected_output=_EXPECTED_OUTPUT_SHAPE			,			)
				def 		__magic_name__(       self			:List[Any]			,			lowerCAmelCase__			:Optional[torch.FloatTensor] = None			,			lowerCAmelCase__			:Optional[bool] = None			,			lowerCAmelCase__			:Optional[bool] = None			,			)		->			Union[Tuple, BaseModelOutputWithNoAttention]:
										__SCREAMING_SNAKE_CASE						:     List[Any]					=		(
										    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
										)
										__SCREAMING_SNAKE_CASE						:     int					=		return_dict if return_dict is not None else self.config.use_return_dict

										if pixel_values is None:
																raise ValueError('''You have to specify pixel_values'''	)

										__SCREAMING_SNAKE_CASE						:     str					=		self.encoder(
										    lowerCAmelCase__			,			output_hidden_states=lowerCAmelCase__			,			return_dict=lowerCAmelCase__			,			)
										__SCREAMING_SNAKE_CASE						:     Tuple					=		encoder_outputs[0]

										if not return_dict:
																return (sequence_output, None) + encoder_outputs[1:]

										return BaseModelOutputWithNoAttention(
										    last_hidden_state=lowerCAmelCase__			,			hidden_states=encoder_outputs.hidden_states			,			)




class        _lowercase      (			nn.Module       ):






				'''simple docstring'''



				def __init__(       self			:str			,			lowerCAmelCase__			:Any	)		->			List[str]:
										super().__init__()
										__SCREAMING_SNAKE_CASE						:     int					=		nn.Linear(config.hidden_size			,			config.hidden_size	)



				def 		__magic_name__(       self			:Union[str, Any]			,			lowerCAmelCase__			:Optional[int]	)		->			List[str]:
										__SCREAMING_SNAKE_CASE						:     Dict					=		self.dense(lowerCAmelCase__	)
										return output




@add_start_docstrings(
    '''
    PoolFormer Model transformer with an image classification head on top
    '''						,			A__						,			)
class        _lowercase      (			A__       ):






				'''simple docstring'''



				def __init__(       self			:Any			,			lowerCAmelCase__			:Any	)		->			Tuple:
										super().__init__(lowerCAmelCase__	)
										__SCREAMING_SNAKE_CASE						:     Tuple					=		config.num_labels
										__SCREAMING_SNAKE_CASE						:     str					=		PoolFormerModel(lowerCAmelCase__	)

										# Final norm
										__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		PoolFormerGroupNorm(config.hidden_sizes[-1]	)
										# Classifier head
										__SCREAMING_SNAKE_CASE						:     int					=		(
										    nn.Linear(config.hidden_sizes[-1]			,			config.num_labels	) if config.num_labels > 0 else nn.Identity()
										)

										# Initialize weights and apply final processing
										self.post_init()



				@add_start_docstrings_to_model_forward(lowerCAmelCase__	)
				@add_code_sample_docstrings(
				    checkpoint=_IMAGE_CLASS_CHECKPOINT			,			output_type=lowerCAmelCase__			,			config_class=_CONFIG_FOR_DOC			,			expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT			,			)
				def 		__magic_name__(       self			:Optional[Any]			,			lowerCAmelCase__			:Optional[torch.FloatTensor] = None			,			lowerCAmelCase__			:Optional[torch.LongTensor] = None			,			lowerCAmelCase__			:Optional[bool] = None			,			lowerCAmelCase__			:Optional[bool] = None			,			)		->			Union[Tuple, ImageClassifierOutputWithNoAttention]:
										__SCREAMING_SNAKE_CASE						:     Any					=		return_dict if return_dict is not None else self.config.use_return_dict

										__SCREAMING_SNAKE_CASE						:     Optional[int]					=		self.poolformer(
										    lowerCAmelCase__			,			output_hidden_states=lowerCAmelCase__			,			return_dict=lowerCAmelCase__			,			)

										__SCREAMING_SNAKE_CASE						:     Dict					=		outputs[0]

										__SCREAMING_SNAKE_CASE						:     Dict					=		self.classifier(self.norm(lowerCAmelCase__	).mean([-2, -1]	)	)

										__SCREAMING_SNAKE_CASE						:     Optional[int]					=		None
										if labels is not None:
																if self.config.problem_type is None:
																						if self.num_labels == 1:
																												__SCREAMING_SNAKE_CASE						:     List[str]					=		'''regression'''
																						elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
																												__SCREAMING_SNAKE_CASE						:     Tuple					=		'''single_label_classification'''
																						else:
																												__SCREAMING_SNAKE_CASE						:     Dict					=		'''multi_label_classification'''

																if self.config.problem_type == "regression":
																						__SCREAMING_SNAKE_CASE						:     Optional[int]					=		MSELoss()
																						if self.num_labels == 1:
																												__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		loss_fct(logits.squeeze()			,			labels.squeeze()	)
																						else:
																												__SCREAMING_SNAKE_CASE						:     int					=		loss_fct(lowerCAmelCase__			,			lowerCAmelCase__	)
																elif self.config.problem_type == "single_label_classification":
																						__SCREAMING_SNAKE_CASE						:     Any					=		CrossEntropyLoss()
																						__SCREAMING_SNAKE_CASE						:     Optional[int]					=		loss_fct(logits.view(-1			,			self.num_labels	)			,			labels.view(-1	)	)
																elif self.config.problem_type == "multi_label_classification":
																						__SCREAMING_SNAKE_CASE						:     List[str]					=		BCEWithLogitsLoss()
																						__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		loss_fct(lowerCAmelCase__			,			lowerCAmelCase__	)

										if not return_dict:
																__SCREAMING_SNAKE_CASE						:     int					=		(logits,) + outputs[2:]
																return ((loss,) + output) if loss is not None else output

										return ImageClassifierOutputWithNoAttention(loss=lowerCAmelCase__			,			logits=lowerCAmelCase__			,			hidden_states=outputs.hidden_states	)




import importlib.metadata
import operator
import re
import sys
from typing import Optional

from packaging import version


__lowerCAmelCase	: Union[str, Any]  				={
    '<': operator.lt,
    '<=': operator.le,
    '==': operator.eq,
    '!=': operator.ne,
    '>=': operator.ge,
    '>': operator.gt,
}


def        _UpperCamelCase							(      lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__      ):
						if got_ver is None or want_ver is None:
												raise ValueError(
												    F'''Unable to compare versions for {requirement}: need={want_ver} found={got_ver}. This is unusual. Consider'''
												    F''' reinstalling {pkg}.'''      )
						if not ops[op](version.parse(lowercase__      )    ,       version.parse(lowercase__      )      ):
												raise ImportError(
												    F'''{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}'''      )


def        _UpperCamelCase							(      lowercase__    ,       lowercase__ = None      ):
						__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		F'''\n{hint}''' if hint is not None else ''''''

						# non-versioned check
						if re.match(R'''^[\w_\-\d]+$'''    ,       lowercase__      ):
												__SCREAMING_SNAKE_CASE			,			__SCREAMING_SNAKE_CASE			,			__SCREAMING_SNAKE_CASE						:     str					=		requirement, None, None
						else:
												__SCREAMING_SNAKE_CASE						:     List[Any]					=		re.findall(R'''^([^!=<>\s]+)([\s!=<>]{1,2}.+)'''    ,       lowercase__      )
												if not match:
																		raise ValueError(
																		    '''requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23, but'''
																		    F''' got {requirement}'''      )
												__SCREAMING_SNAKE_CASE			,			__SCREAMING_SNAKE_CASE						:     Tuple					=		match[0]
												__SCREAMING_SNAKE_CASE						:     Optional[int]					=		want_full.split(''','''      )  # there could be multiple requirements
												__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		{}
												for w in want_range:
																		__SCREAMING_SNAKE_CASE						:     Any					=		re.findall(R'''^([\s!=<>]{1,2})(.+)'''    ,       lowercase__      )
																		if not match:
																								raise ValueError(
																								    '''requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23,'''
																								    F''' but got {requirement}'''      )
																		__SCREAMING_SNAKE_CASE			,			__SCREAMING_SNAKE_CASE						:     Tuple					=		match[0]
																		__SCREAMING_SNAKE_CASE						:     List[Any]					=		want_ver
																		if op not in ops:
																								raise ValueError(F'''{requirement}: need one of {list(ops.keys()      )}, but got {op}'''      )

    # special case
						if pkg == "python":
												__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		'''.'''.join([str(lowercase__      ) for x in sys.version_info[:3]]      )
												for op, want_ver in wanted.items():
																		_compare_versions(lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__      )
												return

						# check if any version is installed
						try:
												__SCREAMING_SNAKE_CASE						:     Optional[int]					=		importlib.metadata.version(lowercase__      )
						except importlib.metadata.PackageNotFoundError:
												raise importlib.metadata.PackageNotFoundError(
												    F'''The \'{requirement}\' distribution was not found and is required by this application. {hint}'''      )

						# check that the right version is installed if version number or a range was provided
						if want_ver is not None:
												for op, want_ver in wanted.items():
																		_compare_versions(lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__      )


def        _UpperCamelCase							(      lowercase__      ):
						__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		'''Try: pip install transformers -U or pip install -e \'.[dev]\' if you\'re working with git main'''
						return require_version(lowercase__    ,       lowercase__      )
