



"""simple docstring"""






from typing import Optional

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

from ...activations import ACTaFN
from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ...modeling_outputs import (
    BaseModelOutputWithNoAttention,
    BaseModelOutputWithPoolingAndNoAttention,
    ImageClassifierOutputWithNoAttention,
)
from ...modeling_utils import PreTrainedModel
from ...utils import logging
from .configuration_regnet import RegNetConfig


__snake_case							:   str      =    logging.get_logger(__name__)

# General docstring
__snake_case							:   Any      =    'RegNetConfig'

# Base docstring
__snake_case							:   int      =    'facebook/regnet-y-040'
__snake_case							:   Dict      =    [1, 1_088, 7, 7]

# Image classification docstring
__snake_case							:   Optional[int]      =    'facebook/regnet-y-040'
__snake_case							:   Tuple      =    'tabby, tabby cat'

__snake_case							:   List[str]      =    [
    'facebook/regnet-y-040',
    # See all regnet models at https://huggingface.co/models?filter=regnet
]



class 			A__   (  nn.Module							):




	'''simple docstring'''





	def __init__(     self:		int       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int = 3       ,			_SCREAMING_SNAKE_CASE:		int = 1       ,			_SCREAMING_SNAKE_CASE:		int = 1       ,			_SCREAMING_SNAKE_CASE:		Optional[str] = "relu"       ,			)				->       List[Any]:

				"""simple docstring"""

				super().__init__()
				__lowerCAmelCase      :  Optional[int]												=       nn.Convad(
				    _SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			kernel_size=_SCREAMING_SNAKE_CASE       ,			stride=_SCREAMING_SNAKE_CASE       ,			padding=kernel_size // 2       ,			groups=_SCREAMING_SNAKE_CASE       ,			bias=_SCREAMING_SNAKE_CASE       ,			)
				__lowerCAmelCase      :  List[Any]												=       nn.BatchNormad(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  Optional[int]												=       ACTaFN[activation] if activation is not None else nn.Identity()







	def 							_SCREAMING_SNAKE_CASE   (     self:		Dict       ,			_SCREAMING_SNAKE_CASE:		Dict)				->       Any:

				"""simple docstring"""

				__lowerCAmelCase      :  List[Any]												=       self.convolution(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  List[Any]												=       self.normalization(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  List[Any]												=       self.activation(_SCREAMING_SNAKE_CASE)
				return hidden_state






class 			A__   (  nn.Module							):




	'''simple docstring'''





	def __init__(     self:		List[Any]       ,			_SCREAMING_SNAKE_CASE:		RegNetConfig)				->       Dict:

				"""simple docstring"""

				super().__init__()
				__lowerCAmelCase      :  Tuple												=       RegNetConvLayer(
				    config.num_channels       ,			config.embedding_size       ,			kernel_size=3       ,			stride=2       ,			activation=config.hidden_act)
				__lowerCAmelCase      :  List[Any]												=       config.num_channels







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

				"""simple docstring"""

				__lowerCAmelCase      :  Any												=       pixel_values.shape[1]
				if num_channels != self.num_channels:
							raise ValueError(
							    "Make sure that the channel dimension of the pixel values match with the one set in the configuration.")
				__lowerCAmelCase      :  Union[str, Any]												=       self.embedder(_SCREAMING_SNAKE_CASE)
				return hidden_state






class 			A__   (  nn.Module							):




	'''simple docstring'''





	def __init__(     self:		str       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int = 2)				->       Any:

				"""simple docstring"""

				super().__init__()
				__lowerCAmelCase      :  Union[str, Any]												=       nn.Convad(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			kernel_size=1       ,			stride=_SCREAMING_SNAKE_CASE       ,			bias=_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  Optional[int]												=       nn.BatchNormad(_SCREAMING_SNAKE_CASE)







	def 							_SCREAMING_SNAKE_CASE   (     self:		List[Any]       ,			_SCREAMING_SNAKE_CASE:		Tensor)				->       Tensor:

				"""simple docstring"""

				__lowerCAmelCase      :  List[Any]												=       self.convolution(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  List[Any]												=       self.normalization(_SCREAMING_SNAKE_CASE)
				return hidden_state






class 			A__   (  nn.Module							):




	'''simple docstring'''





	def __init__(     self:		int       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int)				->       Union[str, Any]:

				"""simple docstring"""

				super().__init__()

				__lowerCAmelCase      :  List[Any]												=       nn.AdaptiveAvgPoolad((1, 1))
				__lowerCAmelCase      :  Tuple												=       nn.Sequential(
				    nn.Convad(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			kernel_size=1)       ,			nn.ReLU()       ,			nn.Convad(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			kernel_size=1)       ,			nn.Sigmoid()       ,			)







	def 							_SCREAMING_SNAKE_CASE   (     self:		Tuple       ,			_SCREAMING_SNAKE_CASE:		Any)				->       Union[str, Any]:

				"""simple docstring"""

				__lowerCAmelCase      :  Optional[Any]												=       self.pooler(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  Dict												=       self.attention(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  Any												=       hidden_state * attention
				return hidden_state






class 			A__   (  nn.Module							):




	'''simple docstring'''





	def __init__(     self:		str       ,			_SCREAMING_SNAKE_CASE:		RegNetConfig       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int = 1)				->       List[Any]:

				"""simple docstring"""

				super().__init__()
				__lowerCAmelCase      :  Optional[Any]												=       in_channels != out_channels or stride != 1
				__lowerCAmelCase      :  Optional[Any]												=       max(1       ,			out_channels // config.groups_width)
				__lowerCAmelCase      :  Dict												=       (
				    RegNetShortCut(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			stride=_SCREAMING_SNAKE_CASE) if should_apply_shortcut else nn.Identity()
				)
				__lowerCAmelCase      :  Dict												=       nn.Sequential(
				    RegNetConvLayer(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			kernel_size=1       ,			activation=config.hidden_act)       ,			RegNetConvLayer(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			stride=_SCREAMING_SNAKE_CASE       ,			groups=_SCREAMING_SNAKE_CASE       ,			activation=config.hidden_act)       ,			RegNetConvLayer(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			kernel_size=1       ,			activation=_SCREAMING_SNAKE_CASE)       ,			)
				__lowerCAmelCase      :  List[str]												=       ACTaFN[config.hidden_act]







	def 							_SCREAMING_SNAKE_CASE   (     self:		Optional[int]       ,			_SCREAMING_SNAKE_CASE:		str)				->       List[Any]:

				"""simple docstring"""

				__lowerCAmelCase      :  Any												=       hidden_state
				__lowerCAmelCase      :  Union[str, Any]												=       self.layer(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  Optional[int]												=       self.shortcut(_SCREAMING_SNAKE_CASE)
				hidden_state += residual
				__lowerCAmelCase      :  Any												=       self.activation(_SCREAMING_SNAKE_CASE)
				return hidden_state






class 			A__   (  nn.Module							):




	'''simple docstring'''





	def __init__(     self:		Union[str, Any]       ,			_SCREAMING_SNAKE_CASE:		RegNetConfig       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int = 1)				->       Optional[int]:

				"""simple docstring"""

				super().__init__()
				__lowerCAmelCase      :  List[Any]												=       in_channels != out_channels or stride != 1
				__lowerCAmelCase      :  str												=       max(1       ,			out_channels // config.groups_width)
				__lowerCAmelCase      :  Optional[Any]												=       (
				    RegNetShortCut(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			stride=_SCREAMING_SNAKE_CASE) if should_apply_shortcut else nn.Identity()
				)
				__lowerCAmelCase      :  List[Any]												=       nn.Sequential(
				    RegNetConvLayer(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			kernel_size=1       ,			activation=config.hidden_act)       ,			RegNetConvLayer(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			stride=_SCREAMING_SNAKE_CASE       ,			groups=_SCREAMING_SNAKE_CASE       ,			activation=config.hidden_act)       ,			RegNetSELayer(_SCREAMING_SNAKE_CASE       ,			reduced_channels=int(round(in_channels / 4)))       ,			RegNetConvLayer(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			kernel_size=1       ,			activation=_SCREAMING_SNAKE_CASE)       ,			)
				__lowerCAmelCase      :  str												=       ACTaFN[config.hidden_act]







	def 							_SCREAMING_SNAKE_CASE   (     self:		Optional[Any]       ,			_SCREAMING_SNAKE_CASE:		str)				->       List[Any]:

				"""simple docstring"""

				__lowerCAmelCase      :  Optional[Any]												=       hidden_state
				__lowerCAmelCase      :  str												=       self.layer(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  Optional[int]												=       self.shortcut(_SCREAMING_SNAKE_CASE)
				hidden_state += residual
				__lowerCAmelCase      :  List[str]												=       self.activation(_SCREAMING_SNAKE_CASE)
				return hidden_state






class 			A__   (  nn.Module							):




	'''simple docstring'''





	def __init__(     self:		int       ,			_SCREAMING_SNAKE_CASE:		RegNetConfig       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int       ,			_SCREAMING_SNAKE_CASE:		int = 2       ,			_SCREAMING_SNAKE_CASE:		int = 2       ,			)				->       Union[str, Any]:

				"""simple docstring"""

				super().__init__()

				__lowerCAmelCase      :  str												=       RegNetXLayer if config.layer_type == "x" else RegNetYLayer

				__lowerCAmelCase      :  List[Any]												=       nn.Sequential(
				    # downsampling is done in the first layer with stride of 2
				    layer(
				        _SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			stride=_SCREAMING_SNAKE_CASE       ,			)       ,			*[layer(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE) for _ in range(depth - 1)]       ,			)







	def 							_SCREAMING_SNAKE_CASE   (     self:		Dict       ,			_SCREAMING_SNAKE_CASE:		List[Any])				->       Any:

				"""simple docstring"""

				__lowerCAmelCase      :  Optional[Any]												=       self.layers(_SCREAMING_SNAKE_CASE)
				return hidden_state






class 			A__   (  nn.Module							):




	'''simple docstring'''





	def __init__(     self:		Any       ,			_SCREAMING_SNAKE_CASE:		RegNetConfig)				->       Union[str, Any]:

				"""simple docstring"""

				super().__init__()
				__lowerCAmelCase      :  Tuple												=       nn.ModuleList([])
				# based on `downsample_in_first_stage`, the first layer of the first stage may or may not downsample the input
				self.stages.append(
				    RegNetStage(
				        _SCREAMING_SNAKE_CASE       ,			config.embedding_size       ,			config.hidden_sizes[0]       ,			stride=2 if config.downsample_in_first_stage else 1       ,			depth=config.depths[0]       ,			))
				__lowerCAmelCase      :  List[str]												=       zip(config.hidden_sizes       ,			config.hidden_sizes[1:])
				for (in_channels, out_channels), depth in zip(_SCREAMING_SNAKE_CASE       ,			config.depths[1:]):
							self.stages.append(RegNetStage(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			depth=_SCREAMING_SNAKE_CASE))







	def 							_SCREAMING_SNAKE_CASE   (     self:		List[Any]       ,			_SCREAMING_SNAKE_CASE:		Tensor       ,			_SCREAMING_SNAKE_CASE:		bool = False       ,			_SCREAMING_SNAKE_CASE:		bool = True)				->       BaseModelOutputWithNoAttention:

				"""simple docstring"""

				__lowerCAmelCase      :  Optional[int]												=       () if output_hidden_states else None

				for stage_module in self.stages:
							if output_hidden_states:
										__lowerCAmelCase      :  int												=       hidden_states + (hidden_state,)

							__lowerCAmelCase      :  List[str]												=       stage_module(_SCREAMING_SNAKE_CASE)

				if output_hidden_states:
							__lowerCAmelCase      :  List[Any]												=       hidden_states + (hidden_state,)

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

				return BaseModelOutputWithNoAttention(last_hidden_state=_SCREAMING_SNAKE_CASE       ,			hidden_states=_SCREAMING_SNAKE_CASE)






class 			A__   (  __SCREAMING_SNAKE_CASE							):




	'''simple docstring'''





	SCREAMING_SNAKE_CASE          =	RegNetConfig
	SCREAMING_SNAKE_CASE          =	'regnet'
	SCREAMING_SNAKE_CASE          =	'pixel_values'
	SCREAMING_SNAKE_CASE          =	True

	def 							_SCREAMING_SNAKE_CASE   (     self:		Optional[int]       ,			_SCREAMING_SNAKE_CASE:		Dict)				->       List[str]:

				"""simple docstring"""

				if isinstance(_SCREAMING_SNAKE_CASE       ,			nn.Convad):
							nn.init.kaiming_normal_(module.weight       ,			mode="fan_out"       ,			nonlinearity="relu")
				elif isinstance(_SCREAMING_SNAKE_CASE       ,			(nn.BatchNormad, nn.GroupNorm)):
							nn.init.constant_(module.weight       ,			1)
							nn.init.constant_(module.bias       ,			0)







	def 							_SCREAMING_SNAKE_CASE   (     self:		int       ,			_SCREAMING_SNAKE_CASE:		Tuple       ,			_SCREAMING_SNAKE_CASE:		Any=False)				->       Optional[int]:

				"""simple docstring"""

				if isinstance(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE):
							__lowerCAmelCase      :  int												=       value






__snake_case							:   Tuple      =    R'\n    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it\n    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 ([`RegNetConfig`]): 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'

__snake_case							:   Optional[Any]      =    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            [`ConvNextImageProcessor.__call__`] for details.\n\n        output_hidden_states (`bool`, *optional*):\n            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for\n            more detail.\n        return_dict (`bool`, *optional*):\n            Whether or not to return a [`~file_utils.ModelOutput`] instead of a plain tuple.\n'



@add_start_docstrings(
    'The bare RegNet model outputting raw features without any specific head on top.'  ,		__SCREAMING_SNAKE_CASE  ,		)
# Copied from transformers.models.resnet.modeling_resnet.ResNetModel with RESNET->REGNET,ResNet->RegNet
class 			A__   (  __SCREAMING_SNAKE_CASE							):




	'''simple docstring'''





	def __init__(     self:		Union[str, Any]       ,			_SCREAMING_SNAKE_CASE:		Dict)				->       List[Any]:

				"""simple docstring"""

				super().__init__(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  Union[str, Any]												=       config
				__lowerCAmelCase      :  Dict												=       RegNetEmbeddings(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  List[Any]												=       RegNetEncoder(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  List[Any]												=       nn.AdaptiveAvgPoolad((1, 1))
				# Initialize weights and apply final processing
				self.post_init()







	@add_start_docstrings_to_model_forward(_SCREAMING_SNAKE_CASE)
	@add_code_sample_docstrings(
	    checkpoint=_CHECKPOINT_FOR_DOC       ,			output_type=_SCREAMING_SNAKE_CASE       ,			config_class=_CONFIG_FOR_DOC       ,			modality="vision"       ,			expected_output=_EXPECTED_OUTPUT_SHAPE       ,			)
	def 							_SCREAMING_SNAKE_CASE   (     self:		Optional[Any]       ,			_SCREAMING_SNAKE_CASE:		Tensor       ,			_SCREAMING_SNAKE_CASE:		Optional[bool] = None       ,			_SCREAMING_SNAKE_CASE:		Optional[bool] = None)				->       BaseModelOutputWithPoolingAndNoAttention:

				"""simple docstring"""

				__lowerCAmelCase      :  List[Any]												=       (
				    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
				)
				__lowerCAmelCase      :  Any												=       return_dict if return_dict is not None else self.config.use_return_dict

				__lowerCAmelCase      :  List[str]												=       self.embedder(_SCREAMING_SNAKE_CASE)

				__lowerCAmelCase      :  Dict												=       self.encoder(
				    _SCREAMING_SNAKE_CASE       ,			output_hidden_states=_SCREAMING_SNAKE_CASE       ,			return_dict=_SCREAMING_SNAKE_CASE)

				__lowerCAmelCase      :  List[Any]												=       encoder_outputs[0]

				__lowerCAmelCase      :  str												=       self.pooler(_SCREAMING_SNAKE_CASE)

				if not return_dict:
							return (last_hidden_state, pooled_output) + encoder_outputs[1:]

				return BaseModelOutputWithPoolingAndNoAttention(
				    last_hidden_state=_SCREAMING_SNAKE_CASE       ,			pooler_output=_SCREAMING_SNAKE_CASE       ,			hidden_states=encoder_outputs.hidden_states       ,			)






@add_start_docstrings(
    '\n    RegNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n    ImageNet.\n    '  ,		__SCREAMING_SNAKE_CASE  ,		)
# Copied from transformers.models.resnet.modeling_resnet.ResNetForImageClassification with RESNET->REGNET,ResNet->RegNet,resnet->regnet
class 			A__   (  __SCREAMING_SNAKE_CASE							):




	'''simple docstring'''





	def __init__(     self:		List[str]       ,			_SCREAMING_SNAKE_CASE:		Tuple)				->       Dict:

				"""simple docstring"""

				super().__init__(_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  Tuple												=       config.num_labels
				__lowerCAmelCase      :  List[str]												=       RegNetModel(_SCREAMING_SNAKE_CASE)
				# classification head
				__lowerCAmelCase      :  int												=       nn.Sequential(
				    nn.Flatten()       ,			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(_SCREAMING_SNAKE_CASE)
	@add_code_sample_docstrings(
	    checkpoint=_IMAGE_CLASS_CHECKPOINT       ,			output_type=_SCREAMING_SNAKE_CASE       ,			config_class=_CONFIG_FOR_DOC       ,			expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT       ,			)
	def 							_SCREAMING_SNAKE_CASE   (     self:		Optional[int]       ,			_SCREAMING_SNAKE_CASE:		Optional[torch.FloatTensor] = None       ,			_SCREAMING_SNAKE_CASE:		Optional[torch.LongTensor] = None       ,			_SCREAMING_SNAKE_CASE:		Optional[bool] = None       ,			_SCREAMING_SNAKE_CASE:		Optional[bool] = None       ,			)				->       ImageClassifierOutputWithNoAttention:

				"""simple docstring"""

				__lowerCAmelCase      :  Any												=       return_dict if return_dict is not None else self.config.use_return_dict

				__lowerCAmelCase      :  Union[str, Any]												=       self.regnet(_SCREAMING_SNAKE_CASE       ,			output_hidden_states=_SCREAMING_SNAKE_CASE       ,			return_dict=_SCREAMING_SNAKE_CASE)

				__lowerCAmelCase      :  str												=       outputs.pooler_output if return_dict else outputs[1]

				__lowerCAmelCase      :  List[Any]												=       self.classifier(_SCREAMING_SNAKE_CASE)

				__lowerCAmelCase      :  List[Any]												=       None

				if labels is not None:
							if self.config.problem_type is None:
										if self.num_labels == 1:
													__lowerCAmelCase      :  List[Any]												=       "regression"
										elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
													__lowerCAmelCase      :  Union[str, Any]												=       "single_label_classification"
										else:
													__lowerCAmelCase      :  Dict												=       "multi_label_classification"
							if self.config.problem_type == "regression":
										__lowerCAmelCase      :  Optional[int]												=       MSELoss()
										if self.num_labels == 1:
													__lowerCAmelCase      :  Optional[Any]												=       loss_fct(logits.squeeze()       ,			labels.squeeze())
										else:
													__lowerCAmelCase      :  Union[str, Any]												=       loss_fct(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE)
							elif self.config.problem_type == "single_label_classification":
										__lowerCAmelCase      :  Optional[Any]												=       CrossEntropyLoss()
										__lowerCAmelCase      :  Dict												=       loss_fct(logits.view(-1       ,			self.num_labels)       ,			labels.view(-1))
							elif self.config.problem_type == "multi_label_classification":
										__lowerCAmelCase      :  Tuple												=       BCEWithLogitsLoss()
										__lowerCAmelCase      :  List[Any]												=       loss_fct(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE)

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

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




"""simple docstring"""






def 			_lowercase				(  )						->   int:
			return 1


def 			_lowercase				(  __snake_case	)						->   int:
			return 0 if x < 0 else two_pence(x - 2	) + one_pence()


def 			_lowercase				(  __snake_case	)						->   int:
			return 0 if x < 0 else five_pence(x - 5	) + two_pence(__snake_case	)


def 			_lowercase				(  __snake_case	)						->   int:
			return 0 if x < 0 else ten_pence(x - 10	) + five_pence(__snake_case	)


def 			_lowercase				(  __snake_case	)						->   int:
			return 0 if x < 0 else twenty_pence(x - 20	) + ten_pence(__snake_case	)


def 			_lowercase				(  __snake_case	)						->   int:
			return 0 if x < 0 else fifty_pence(x - 50	) + twenty_pence(__snake_case	)


def 			_lowercase				(  __snake_case	)						->   int:
			return 0 if x < 0 else one_pound(x - 100	) + fifty_pence(__snake_case	)


def 			_lowercase				(  __snake_case	)						->   int:
			return 0 if x < 0 else two_pound(x - 200	) + one_pound(__snake_case	)


def 			_lowercase				(  __snake_case = 200	)						->   int:
			return two_pound(__snake_case	)


if __name__ == "__main__":
	print(solution(int(input().strip())))