





from typing import List, Optional, Tuple, Union

import torch

from ...models import UNetaDModel
from ...schedulers import KarrasVeScheduler
from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput



class        _SCREAMING_SNAKE_CASE						(     __SCREAMING_SNAKE_CASE   ):







 '''simple docstring'''
 lowercase_		=      42
 lowercase_		=      42

 def __init__(self    :       Dict	,			UpperCAmelCase_    :       UNetaDModel	,			UpperCAmelCase_    :       KarrasVeScheduler)	->Any:



   '''simple docstring'''



   super().__init__()
   self.register_modules(unet=UpperCAmelCase_	,			scheduler=UpperCAmelCase_)







 @torch.no_grad()
 def __call__(self    :       str	,			UpperCAmelCase_    :       int = 1	,			UpperCAmelCase_    :       int = 50	,			UpperCAmelCase_    :       Optional[Union[torch.Generator, List[torch.Generator]]] = None	,			UpperCAmelCase_    :       Optional[str] = "pil"	,			UpperCAmelCase_    :       bool = True	,			**UpperCAmelCase_    :       Optional[Any]	,			)	->Union[Tuple, ImagePipelineOutput]:



   '''simple docstring'''



   lowerCamelCase__:				int        =self.unet.config.sample_size
   lowerCamelCase__:				List[Any]        =(batch_size, 3, img_size, img_size)

   lowerCamelCase__:				Optional[int]        =self.unet

   # sample x_0 ~ N(0, sigma_0^2 * I)
   lowerCamelCase__:				List[Any]        =randn_tensor(UpperCAmelCase_	,			generator=UpperCAmelCase_	,			device=self.device) * self.scheduler.init_noise_sigma

   self.scheduler.set_timesteps(UpperCAmelCase_)

   for t in self.progress_bar(self.scheduler.timesteps):
     # here sigma_t == t_i from the paper
     lowerCamelCase__:				Dict        =self.scheduler.schedule[t]
     lowerCamelCase__:				Optional[int]        =self.scheduler.schedule[t - 1] if t > 0 else 0

     # 1. Select temporarily increased noise level sigma_hat
     # 2. Add new noise to move from sample_i to sample_hat
     lowerCamelCase__:				List[Any]        =self.scheduler.add_noise_to_input(UpperCAmelCase_	,			UpperCAmelCase_	,			generator=UpperCAmelCase_)

     # 3. Predict the noise residual given the noise magnitude `sigma_hat`
     # The model inputs and output are adjusted by following eq. (213) in [1].
     lowerCamelCase__:				Any        =(sigma_hat / 2) * model((sample_hat + 1) / 2	,			sigma_hat / 2).sample

     # 4. Evaluate dx/dt at sigma_hat
     # 5. Take Euler step from sigma to sigma_prev
     lowerCamelCase__:				List[str]        =self.scheduler.step(UpperCAmelCase_	,			UpperCAmelCase_	,			UpperCAmelCase_	,			UpperCAmelCase_)

     if sigma_prev != 0:
       # 6. Apply 2nd order correction
       # The model inputs and output are adjusted by following eq. (213) in [1].
       lowerCamelCase__:				int        =(sigma_prev / 2) * model((step_output.prev_sample + 1) / 2	,			sigma_prev / 2).sample
       lowerCamelCase__:				Any        =self.scheduler.step_correct(
           UpperCAmelCase_	,			UpperCAmelCase_	,			UpperCAmelCase_	,			UpperCAmelCase_	,			step_output.prev_sample	,			step_output["derivative"]	,			)
     lowerCamelCase__:				Union[str, Any]        =step_output.prev_sample

   lowerCamelCase__:				Optional[Any]        =(sample / 2 + 0.5).clamp(0	,			1)
   lowerCamelCase__:				int        =sample.cpu().permute(0	,			2	,			3	,			1).numpy()
   if output_type == "pil":
     lowerCamelCase__:				Optional[Any]        =self.numpy_to_pil(UpperCAmelCase_)

   if not return_dict:
     return (image,)

   return ImagePipelineOutput(images=UpperCAmelCase_)








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 ...modeling_outputs import (
    BackboneOutput,
    BaseModelOutputWithNoAttention,
    BaseModelOutputWithPoolingAndNoAttention,
    ImageClassifierOutputWithNoAttention,
)
from ...modeling_utils import PreTrainedModel
from ...utils import (
    add_code_sample_docstrings,
    add_start_docstrings,
    add_start_docstrings_to_model_forward,
    logging,
    replace_return_docstrings,
)
from ...utils.backbone_utils import BackboneMixin
from .configuration_resnet import ResNetConfig


__A     =    logging.get_logger(__name__)

# General docstring
__A     =    "ResNetConfig"

# Base docstring
__A     =    "microsoft/resnet-50"
__A     =    [1, 2048, 7, 7]

# Image classification docstring
__A     =    "microsoft/resnet-50"
__A     =    "tiger cat"

__A     =    [
    "microsoft/resnet-50",
    # See all resnet models at https://huggingface.co/models?filter=resnet
]



class        _SCREAMING_SNAKE_CASE						(     nn.Module   ):







 '''simple docstring'''

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



   '''simple docstring'''



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







 def 							SCREAMING_SNAKE_CASE_ (self    :       Tuple	,			UpperCAmelCase_    :       Tensor)	->Tensor:



   '''simple docstring'''



   lowerCamelCase__:				List[Any]        =self.convolution(UpperCAmelCase_)
   lowerCamelCase__:				List[str]        =self.normalization(UpperCAmelCase_)
   lowerCamelCase__:				Optional[Any]        =self.activation(UpperCAmelCase_)
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     nn.Module   ):







 '''simple docstring'''

 def __init__(self    :       Any	,			UpperCAmelCase_    :       ResNetConfig)	->str:



   '''simple docstring'''



   super().__init__()
   lowerCamelCase__:				Tuple        =ResNetConvLayer(
       config.num_channels	,			config.embedding_size	,			kernel_size=7	,			stride=2	,			activation=config.hidden_act)
   lowerCamelCase__:				Optional[int]        =nn.MaxPoolad(kernel_size=3	,			stride=2	,			padding=1)
   lowerCamelCase__:				Optional[Any]        =config.num_channels







 def 							SCREAMING_SNAKE_CASE_ (self    :       Union[str, Any]	,			UpperCAmelCase_    :       Tensor)	->Tensor:



   '''simple docstring'''



   lowerCamelCase__:				Optional[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__:				Dict        =self.embedder(UpperCAmelCase_)
   lowerCamelCase__:				str        =self.pooler(UpperCAmelCase_)
   return embedding



class        _SCREAMING_SNAKE_CASE						(     nn.Module   ):







 '''simple docstring'''

 def __init__(self    :       List[str]	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int = 2)	->Any:



   '''simple docstring'''



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







 def 							SCREAMING_SNAKE_CASE_ (self    :       Optional[int]	,			UpperCAmelCase_    :       Tensor)	->Tensor:



   '''simple docstring'''



   lowerCamelCase__:				Optional[int]        =self.convolution(UpperCAmelCase_)
   lowerCamelCase__:				Any        =self.normalization(UpperCAmelCase_)
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     nn.Module   ):







 '''simple docstring'''

 def __init__(self    :       Tuple	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int = 1	,			UpperCAmelCase_    :       str = "relu")	->Tuple:



   '''simple docstring'''



   super().__init__()
   lowerCamelCase__:				Tuple        =in_channels != out_channels or stride != 1
   lowerCamelCase__:				str        =(
       ResNetShortCut(UpperCAmelCase_	,			UpperCAmelCase_	,			stride=UpperCAmelCase_) if should_apply_shortcut else nn.Identity()
   )
   lowerCamelCase__:				Tuple        =nn.Sequential(
       ResNetConvLayer(UpperCAmelCase_	,			UpperCAmelCase_	,			stride=UpperCAmelCase_)	,			ResNetConvLayer(UpperCAmelCase_	,			UpperCAmelCase_	,			activation=UpperCAmelCase_)	,			)
   lowerCamelCase__:				Optional[Any]        =ACTaFN[activation]







 def 							SCREAMING_SNAKE_CASE_ (self    :       Tuple	,			UpperCAmelCase_    :       Any)	->Optional[Any]:



   '''simple docstring'''



   lowerCamelCase__:				Any        =hidden_state
   lowerCamelCase__:				List[str]        =self.layer(UpperCAmelCase_)
   lowerCamelCase__:				str        =self.shortcut(UpperCAmelCase_)
   hidden_state += residual
   lowerCamelCase__:				Dict        =self.activation(UpperCAmelCase_)
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     nn.Module   ):







 '''simple docstring'''

 def __init__(self    :       List[str]	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int = 1	,			UpperCAmelCase_    :       str = "relu"	,			UpperCAmelCase_    :       int = 4)	->Tuple:



   '''simple docstring'''



   super().__init__()
   lowerCamelCase__:				Union[str, Any]        =in_channels != out_channels or stride != 1
   lowerCamelCase__:				List[str]        =out_channels // reduction
   lowerCamelCase__:				Optional[Any]        =(
       ResNetShortCut(UpperCAmelCase_	,			UpperCAmelCase_	,			stride=UpperCAmelCase_) if should_apply_shortcut else nn.Identity()
   )
   lowerCamelCase__:				Dict        =nn.Sequential(
       ResNetConvLayer(UpperCAmelCase_	,			UpperCAmelCase_	,			kernel_size=1)	,			ResNetConvLayer(UpperCAmelCase_	,			UpperCAmelCase_	,			stride=UpperCAmelCase_)	,			ResNetConvLayer(UpperCAmelCase_	,			UpperCAmelCase_	,			kernel_size=1	,			activation=UpperCAmelCase_)	,			)
   lowerCamelCase__:				Tuple        =ACTaFN[activation]







 def 							SCREAMING_SNAKE_CASE_ (self    :       int	,			UpperCAmelCase_    :       List[str])	->int:



   '''simple docstring'''



   lowerCamelCase__:				str        =hidden_state
   lowerCamelCase__:				Optional[Any]        =self.layer(UpperCAmelCase_)
   lowerCamelCase__:				List[Any]        =self.shortcut(UpperCAmelCase_)
   hidden_state += residual
   lowerCamelCase__:				Tuple        =self.activation(UpperCAmelCase_)
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     nn.Module   ):







 '''simple docstring'''

 def __init__(self    :       str	,			UpperCAmelCase_    :       ResNetConfig	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int = 2	,			UpperCAmelCase_    :       int = 2	,			)	->Dict:



   '''simple docstring'''



   super().__init__()

   lowerCamelCase__:				List[Any]        =ResNetBottleNeckLayer if config.layer_type == "bottleneck" else ResNetBasicLayer

   lowerCamelCase__:				List[str]        =nn.Sequential(
       # downsampling is done in the first layer with stride of 2
       layer(UpperCAmelCase_	,			UpperCAmelCase_	,			stride=UpperCAmelCase_	,			activation=config.hidden_act)	,			*[layer(UpperCAmelCase_	,			UpperCAmelCase_	,			activation=config.hidden_act) for _ in range(depth - 1)]	,			)







 def 							SCREAMING_SNAKE_CASE_ (self    :       Tuple	,			UpperCAmelCase_    :       Tensor)	->Tensor:



   '''simple docstring'''



   lowerCamelCase__:				List[Any]        =input
   for layer in self.layers:
     lowerCamelCase__:				Any        =layer(UpperCAmelCase_)
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     nn.Module   ):







 '''simple docstring'''

 def __init__(self    :       int	,			UpperCAmelCase_    :       ResNetConfig)	->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(
       ResNetStage(
           UpperCAmelCase_	,			config.embedding_size	,			config.hidden_sizes[0]	,			stride=2 if config.downsample_in_first_stage else 1	,			depth=config.depths[0]	,			))
   lowerCamelCase__:				int        =zip(config.hidden_sizes	,			config.hidden_sizes[1:])
   for (in_channels, out_channels), depth in zip(UpperCAmelCase_	,			config.depths[1:]):
     self.stages.append(ResNetStage(UpperCAmelCase_	,			UpperCAmelCase_	,			UpperCAmelCase_	,			depth=UpperCAmelCase_))







 def 							SCREAMING_SNAKE_CASE_ (self    :       Tuple	,			UpperCAmelCase_    :       Tensor	,			UpperCAmelCase_    :       bool = False	,			UpperCAmelCase_    :       bool = True)	->BaseModelOutputWithNoAttention:



   '''simple docstring'''



   lowerCamelCase__:				str        =() if output_hidden_states else None

   for stage_module in self.stages:
     if output_hidden_states:
       lowerCamelCase__:				Union[str, Any]        =hidden_states + (hidden_state,)

     lowerCamelCase__:				str        =stage_module(UpperCAmelCase_)

   if output_hidden_states:
     lowerCamelCase__:				Optional[int]        =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=UpperCAmelCase_	,			hidden_states=UpperCAmelCase_	,			)



class        _SCREAMING_SNAKE_CASE						(     __SCREAMING_SNAKE_CASE   ):







 '''simple docstring'''
 lowercase_		=      ResNetConfig
 lowercase_		=      "resnet"
 lowercase_		=      "pixel_values"
 lowercase_		=      True

 def 							SCREAMING_SNAKE_CASE_ (self    :       List[str]	,			UpperCAmelCase_    :       int)	->Any:



   '''simple docstring'''



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







 def 							SCREAMING_SNAKE_CASE_ (self    :       Any	,			UpperCAmelCase_    :       Optional[Any]	,			UpperCAmelCase_    :       List[Any]=False)	->Any:



   '''simple docstring'''



   if isinstance(UpperCAmelCase_	,			UpperCAmelCase_):
     lowerCamelCase__:				List[str]        =value



__A     =    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 ([`ResNetConfig`]): 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"

__A     =    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 [`~utils.ModelOutput`] instead of a plain tuple.\n"



@add_start_docstrings(
    "The bare ResNet model outputting raw features without any specific head on top."   ,							__SCREAMING_SNAKE_CASE   ,							)
class        _SCREAMING_SNAKE_CASE						(     __SCREAMING_SNAKE_CASE   ):







 '''simple docstring'''

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



   '''simple docstring'''



   super().__init__(UpperCAmelCase_)
   lowerCamelCase__:				str        =config
   lowerCamelCase__:				str        =ResNetEmbeddings(UpperCAmelCase_)
   lowerCamelCase__:				Optional[Any]        =ResNetEncoder(UpperCAmelCase_)
   lowerCamelCase__:				Optional[Any]        =nn.AdaptiveAvgPoolad((1, 1))
   # Initialize weights and apply final processing
   self.post_init()







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



   '''simple docstring'''



   lowerCamelCase__:				Optional[int]        =(
       output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
   )
   lowerCamelCase__:				Optional[int]        =return_dict if return_dict is not None else self.config.use_return_dict

   lowerCamelCase__:				int        =self.embedder(UpperCAmelCase_)

   lowerCamelCase__:				int        =self.encoder(
       UpperCAmelCase_	,			output_hidden_states=UpperCAmelCase_	,			return_dict=UpperCAmelCase_)

   lowerCamelCase__:				int        =encoder_outputs[0]

   lowerCamelCase__:				Tuple        =self.pooler(UpperCAmelCase_)

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

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



@add_start_docstrings(
    "\n    ResNet 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   ,							)
class        _SCREAMING_SNAKE_CASE						(     __SCREAMING_SNAKE_CASE   ):







 '''simple docstring'''

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



   '''simple docstring'''



   super().__init__(UpperCAmelCase_)
   lowerCamelCase__:				int        =config.num_labels
   lowerCamelCase__:				Optional[Any]        =ResNetModel(UpperCAmelCase_)
   # classification head
   lowerCamelCase__:				Optional[Any]        =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(UpperCAmelCase_)
 @add_code_sample_docstrings(
     checkpoint=_IMAGE_CLASS_CHECKPOINT	,			output_type=UpperCAmelCase_	,			config_class=_CONFIG_FOR_DOC	,			expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT	,			)
 def 							SCREAMING_SNAKE_CASE_ (self    :       Union[str, Any]	,			UpperCAmelCase_    :       Optional[torch.FloatTensor] = None	,			UpperCAmelCase_    :       Optional[torch.LongTensor] = None	,			UpperCAmelCase_    :       Optional[bool] = None	,			UpperCAmelCase_    :       Optional[bool] = None	,			)	->ImageClassifierOutputWithNoAttention:



   '''simple docstring'''



   lowerCamelCase__:				Optional[int]        =return_dict if return_dict is not None else self.config.use_return_dict

   lowerCamelCase__:				List[Any]        =self.resnet(UpperCAmelCase_	,			output_hidden_states=UpperCAmelCase_	,			return_dict=UpperCAmelCase_)

   lowerCamelCase__:				int        =outputs.pooler_output if return_dict else outputs[1]

   lowerCamelCase__:				Dict        =self.classifier(UpperCAmelCase_)

   lowerCamelCase__:				Optional[Any]        =None

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

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

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



@add_start_docstrings(
    "\n    ResNet backbone, to be used with frameworks like DETR and MaskFormer.\n    "   ,							__SCREAMING_SNAKE_CASE   ,							)
class        _SCREAMING_SNAKE_CASE						(     __SCREAMING_SNAKE_CASE   ,							__SCREAMING_SNAKE_CASE   ):







 '''simple docstring'''

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



   '''simple docstring'''



   super().__init__(UpperCAmelCase_)
   super()._init_backbone(UpperCAmelCase_)

   lowerCamelCase__:				int        =[config.embedding_size] + config.hidden_sizes
   lowerCamelCase__:				List[Any]        =ResNetEmbeddings(UpperCAmelCase_)
   lowerCamelCase__:				Optional[int]        =ResNetEncoder(UpperCAmelCase_)

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







 @add_start_docstrings_to_model_forward(UpperCAmelCase_)
 @replace_return_docstrings(output_type=UpperCAmelCase_	,			config_class=_CONFIG_FOR_DOC)
 def 							SCREAMING_SNAKE_CASE_ (self    :       Union[str, Any]	,			UpperCAmelCase_    :       Tensor	,			UpperCAmelCase_    :       Optional[bool] = None	,			UpperCAmelCase_    :       Optional[bool] = None)	->BackboneOutput:



   '''simple docstring'''



   lowerCamelCase__:				Optional[Any]        =return_dict if return_dict is not None else self.config.use_return_dict
   lowerCamelCase__:				Union[str, Any]        =(
       output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
   )

   lowerCamelCase__:				int        =self.embedder(UpperCAmelCase_)

   lowerCamelCase__:				Optional[Any]        =self.encoder(UpperCAmelCase_	,			output_hidden_states=UpperCAmelCase_	,			return_dict=UpperCAmelCase_)

   lowerCamelCase__:				Any        =outputs.hidden_states

   lowerCamelCase__:				int        =()
   for idx, stage in enumerate(self.stage_names):
     if stage in self.out_features:
       feature_maps += (hidden_states[idx],)

   if not return_dict:
     lowerCamelCase__:				Dict        =(feature_maps,)
     if output_hidden_states:
       output += (outputs.hidden_states,)
     return output

   return BackboneOutput(
       feature_maps=UpperCAmelCase_	,			hidden_states=outputs.hidden_states if output_hidden_states else None	,			attentions=UpperCAmelCase_	,			)

