





from typing import Optional, Tuple, Union

import tensorflow as tf

from ...activations_tf import ACTaFN
from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ...modeling_tf_outputs import (
    TFBaseModelOutputWithNoAttention,
    TFBaseModelOutputWithPoolingAndNoAttention,
    TFSequenceClassifierOutput,
)
from ...modeling_tf_utils import TFPreTrainedModel, TFSequenceClassificationLoss, keras_serializable, unpack_inputs
from ...tf_utils import shape_list
from ...utils import logging
from .configuration_regnet import RegNetConfig


__A     =    logging.get_logger(__name__)

# General docstring
__A     =    "RegNetConfig"

# Base docstring
__A     =    "facebook/regnet-y-040"
__A     =    [1, 1088, 7, 7]

# Image classification docstring
__A     =    "facebook/regnet-y-040"
__A     =    "tabby, tabby cat"

__A     =    [
    "facebook/regnet-y-040",
    # See all regnet models at https://huggingface.co/models?filter=regnet
]



class        _SCREAMING_SNAKE_CASE						(     tf.keras.layers.Layer   ):







 '''simple docstring'''

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



   '''simple docstring'''



   super().__init__(**UpperCAmelCase_)
   # The padding and conv has been verified in
   # https://colab.research.google.com/gist/sayakpaul/854bc10eeaf21c9ee2119e0b9f3841a7/scratchpad.ipynb
   lowerCamelCase__:				int        =tf.keras.layers.ZeroPaddingaD(padding=kernel_size // 2)
   lowerCamelCase__:				Any        =tf.keras.layers.ConvaD(
       filters=UpperCAmelCase_	,			kernel_size=UpperCAmelCase_	,			strides=UpperCAmelCase_	,			padding="VALID"	,			groups=UpperCAmelCase_	,			use_bias=UpperCAmelCase_	,			name="convolution"	,			)
   lowerCamelCase__:				List[Any]        =tf.keras.layers.BatchNormalization(epsilon=1E-5	,			momentum=0.9	,			name="normalization")
   lowerCamelCase__:				str        =ACTaFN[activation] if activation is not None else tf.identity







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



   '''simple docstring'''



   lowerCamelCase__:				Dict        =self.convolution(self.padding(UpperCAmelCase_))
   lowerCamelCase__:				Any        =self.normalization(UpperCAmelCase_)
   lowerCamelCase__:				Union[str, Any]        =self.activation(UpperCAmelCase_)
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     tf.keras.layers.Layer   ):







 '''simple docstring'''

 def __init__(self    :       Optional[int]	,			UpperCAmelCase_    :       RegNetConfig	,			**UpperCAmelCase_    :       Any)	->List[str]:



   '''simple docstring'''



   super().__init__(**UpperCAmelCase_)
   lowerCamelCase__:				Optional[Any]        =config.num_channels
   lowerCamelCase__:				Optional[int]        =TFRegNetConvLayer(
       out_channels=config.embedding_size	,			kernel_size=3	,			stride=2	,			activation=config.hidden_act	,			name="embedder"	,			)







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



   '''simple docstring'''



   lowerCamelCase__:				Union[str, Any]        =shape_list(UpperCAmelCase_)[1]
   if tf.executing_eagerly() and 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.")

   # When running on CPU, `tf.keras.layers.Conv2D` doesn't support `NCHW` format.
   # So change the input format from `NCHW` to `NHWC`.
   # shape = (batch_size, in_height, in_width, in_channels=num_channels)
   lowerCamelCase__:				Tuple        =tf.transpose(UpperCAmelCase_	,			perm=(0, 2, 3, 1))
   lowerCamelCase__:				Tuple        =self.embedder(UpperCAmelCase_)
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     tf.keras.layers.Layer   ):







 '''simple docstring'''

 def __init__(self    :       Optional[int]	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int = 2	,			**UpperCAmelCase_    :       Union[str, Any])	->Dict:



   '''simple docstring'''



   super().__init__(**UpperCAmelCase_)
   lowerCamelCase__:				List[str]        =tf.keras.layers.ConvaD(
       filters=UpperCAmelCase_	,			kernel_size=1	,			strides=UpperCAmelCase_	,			use_bias=UpperCAmelCase_	,			name="convolution")
   lowerCamelCase__:				List[str]        =tf.keras.layers.BatchNormalization(epsilon=1E-5	,			momentum=0.9	,			name="normalization")







 def 							SCREAMING_SNAKE_CASE_ (self    :       Dict	,			UpperCAmelCase_    :       tf.Tensor	,			UpperCAmelCase_    :       bool = False)	->tf.Tensor:



   '''simple docstring'''



   return self.normalization(self.convolution(UpperCAmelCase_)	,			training=UpperCAmelCase_)



class        _SCREAMING_SNAKE_CASE						(     tf.keras.layers.Layer   ):







 '''simple docstring'''

 def __init__(self    :       Tuple	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int	,			**UpperCAmelCase_    :       Optional[int])	->str:



   '''simple docstring'''



   super().__init__(**UpperCAmelCase_)
   lowerCamelCase__:				Optional[int]        =tf.keras.layers.GlobalAveragePoolingaD(keepdims=UpperCAmelCase_	,			name="pooler")
   lowerCamelCase__:				List[Any]        =[
       tf.keras.layers.ConvaD(filters=UpperCAmelCase_	,			kernel_size=1	,			activation="relu"	,			name="attention.0"),
       tf.keras.layers.ConvaD(filters=UpperCAmelCase_	,			kernel_size=1	,			activation="sigmoid"	,			name="attention.2"),
   ]







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



   '''simple docstring'''



   lowerCamelCase__:				Optional[int]        =self.pooler(UpperCAmelCase_)
   for layer_module in self.attention:
     lowerCamelCase__:				Union[str, Any]        =layer_module(UpperCAmelCase_)
   lowerCamelCase__:				Union[str, Any]        =hidden_state * pooled
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     tf.keras.layers.Layer   ):







 '''simple docstring'''

 def __init__(self    :       Tuple	,			UpperCAmelCase_    :       RegNetConfig	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int = 1	,			**UpperCAmelCase_    :       Union[str, Any])	->Any:



   '''simple docstring'''



   super().__init__(**UpperCAmelCase_)
   lowerCamelCase__:				Optional[Any]        =in_channels != out_channels or stride != 1
   lowerCamelCase__:				List[str]        =max(1	,			out_channels // config.groups_width)
   lowerCamelCase__:				List[Any]        =(
       TFRegNetShortCut(UpperCAmelCase_	,			stride=UpperCAmelCase_	,			name="shortcut")
       if should_apply_shortcut
       else tf.keras.layers.Activation("linear"	,			name="shortcut")
   )
   # `self.layers` instead of `self.layer` because that is a reserved argument.
   lowerCamelCase__:				str        =[
       TFRegNetConvLayer(UpperCAmelCase_	,			kernel_size=1	,			activation=config.hidden_act	,			name="layer.0"),
       TFRegNetConvLayer(
           UpperCAmelCase_	,			stride=UpperCAmelCase_	,			groups=UpperCAmelCase_	,			activation=config.hidden_act	,			name="layer.1"),
       TFRegNetConvLayer(UpperCAmelCase_	,			kernel_size=1	,			activation=UpperCAmelCase_	,			name="layer.2"),
   ]
   lowerCamelCase__:				Tuple        =ACTaFN[config.hidden_act]







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



   '''simple docstring'''



   lowerCamelCase__:				List[Any]        =hidden_state
   for layer_module in self.layers:
     lowerCamelCase__:				Union[str, Any]        =layer_module(UpperCAmelCase_)
   lowerCamelCase__:				str        =self.shortcut(UpperCAmelCase_)
   hidden_state += residual
   lowerCamelCase__:				Optional[int]        =self.activation(UpperCAmelCase_)
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     tf.keras.layers.Layer   ):







 '''simple docstring'''

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



   '''simple docstring'''



   super().__init__(**UpperCAmelCase_)
   lowerCamelCase__:				Union[str, Any]        =in_channels != out_channels or stride != 1
   lowerCamelCase__:				Tuple        =max(1	,			out_channels // config.groups_width)
   lowerCamelCase__:				List[Any]        =(
       TFRegNetShortCut(UpperCAmelCase_	,			stride=UpperCAmelCase_	,			name="shortcut")
       if should_apply_shortcut
       else tf.keras.layers.Activation("linear"	,			name="shortcut")
   )
   lowerCamelCase__:				List[Any]        =[
       TFRegNetConvLayer(UpperCAmelCase_	,			kernel_size=1	,			activation=config.hidden_act	,			name="layer.0"),
       TFRegNetConvLayer(
           UpperCAmelCase_	,			stride=UpperCAmelCase_	,			groups=UpperCAmelCase_	,			activation=config.hidden_act	,			name="layer.1"),
       TFRegNetSELayer(UpperCAmelCase_	,			reduced_channels=int(round(in_channels / 4))	,			name="layer.2"),
       TFRegNetConvLayer(UpperCAmelCase_	,			kernel_size=1	,			activation=UpperCAmelCase_	,			name="layer.3"),
   ]
   lowerCamelCase__:				str        =ACTaFN[config.hidden_act]







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



   '''simple docstring'''



   lowerCamelCase__:				Optional[Any]        =hidden_state
   for layer_module in self.layers:
     lowerCamelCase__:				int        =layer_module(UpperCAmelCase_)
   lowerCamelCase__:				List[str]        =self.shortcut(UpperCAmelCase_)
   hidden_state += residual
   lowerCamelCase__:				Any        =self.activation(UpperCAmelCase_)
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     tf.keras.layers.Layer   ):







 '''simple docstring'''

 def __init__(self    :       Tuple	,			UpperCAmelCase_    :       RegNetConfig	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       int = 2	,			UpperCAmelCase_    :       int = 2	,			**UpperCAmelCase_    :       int)	->Optional[int]:



   '''simple docstring'''



   super().__init__(**UpperCAmelCase_)

   lowerCamelCase__:				Optional[Any]        =TFRegNetXLayer if config.layer_type == "x" else TFRegNetYLayer
   lowerCamelCase__:				Dict        =[
       # downsampling is done in the first layer with stride of 2
       layer(UpperCAmelCase_	,			UpperCAmelCase_	,			UpperCAmelCase_	,			stride=UpperCAmelCase_	,			name="layers.0"),
       *[layer(UpperCAmelCase_	,			UpperCAmelCase_	,			UpperCAmelCase_	,			name=F"""layers.{i+1}""") for i in range(depth - 1)],
   ]







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



   '''simple docstring'''



   for layer_module in self.layers:
     lowerCamelCase__:				Any        =layer_module(UpperCAmelCase_)
   return hidden_state



class        _SCREAMING_SNAKE_CASE						(     tf.keras.layers.Layer   ):







 '''simple docstring'''

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



   '''simple docstring'''



   super().__init__(**UpperCAmelCase_)
   lowerCamelCase__:				List[Any]        =[]
   # based on `downsample_in_first_stage`, the first layer of the first stage may or may not downsample the input
   self.stages.append(
       TFRegNetStage(
           UpperCAmelCase_	,			config.embedding_size	,			config.hidden_sizes[0]	,			stride=2 if config.downsample_in_first_stage else 1	,			depth=config.depths[0]	,			name="stages.0"	,			))
   lowerCamelCase__:				Tuple        =zip(config.hidden_sizes	,			config.hidden_sizes[1:])
   for i, ((in_channels, out_channels), depth) in enumerate(zip(UpperCAmelCase_	,			config.depths[1:])):
     self.stages.append(TFRegNetStage(UpperCAmelCase_	,			UpperCAmelCase_	,			UpperCAmelCase_	,			depth=UpperCAmelCase_	,			name=F"""stages.{i+1}"""))







 def 							SCREAMING_SNAKE_CASE_ (self    :       Union[str, Any]	,			UpperCAmelCase_    :       tf.Tensor	,			UpperCAmelCase_    :       bool = False	,			UpperCAmelCase_    :       bool = True)	->TFBaseModelOutputWithNoAttention:



   '''simple docstring'''



   lowerCamelCase__:				List[str]        =() if output_hidden_states else None

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

     lowerCamelCase__:				Dict        =stage_module(UpperCAmelCase_)

   if output_hidden_states:
     lowerCamelCase__:				Tuple        =hidden_states + (hidden_state,)

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

   return TFBaseModelOutputWithNoAttention(last_hidden_state=UpperCAmelCase_	,			hidden_states=UpperCAmelCase_)



@keras_serializable
class        _SCREAMING_SNAKE_CASE						(     tf.keras.layers.Layer   ):







 '''simple docstring'''
 lowercase_		=      RegNetConfig

 def __init__(self    :       Union[str, Any]	,			UpperCAmelCase_    :       Optional[Any]	,			**UpperCAmelCase_    :       List[str])	->List[Any]:



   '''simple docstring'''



   super().__init__(**UpperCAmelCase_)
   lowerCamelCase__:				int        =config
   lowerCamelCase__:				Optional[int]        =TFRegNetEmbeddings(UpperCAmelCase_	,			name="embedder")
   lowerCamelCase__:				Dict        =TFRegNetEncoder(UpperCAmelCase_	,			name="encoder")
   lowerCamelCase__:				Any        =tf.keras.layers.GlobalAveragePoolingaD(keepdims=UpperCAmelCase_	,			name="pooler")







 @unpack_inputs
 def 							SCREAMING_SNAKE_CASE_ (self    :       Tuple	,			UpperCAmelCase_    :       tf.Tensor	,			UpperCAmelCase_    :       Optional[bool] = None	,			UpperCAmelCase_    :       Optional[bool] = None	,			UpperCAmelCase_    :       bool = False	,			)	->TFBaseModelOutputWithPoolingAndNoAttention:



   '''simple docstring'''



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

   lowerCamelCase__:				Optional[Any]        =self.embedder(UpperCAmelCase_	,			training=UpperCAmelCase_)

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

   lowerCamelCase__:				str        =encoder_outputs[0]
   lowerCamelCase__:				Optional[Any]        =self.pooler(UpperCAmelCase_)

   # Change to NCHW output format have uniformity in the modules
   lowerCamelCase__:				Any        =tf.transpose(UpperCAmelCase_	,			perm=(0, 3, 1, 2))
   lowerCamelCase__:				Optional[int]        =tf.transpose(UpperCAmelCase_	,			perm=(0, 3, 1, 2))

   # Change the other hidden state outputs to NCHW as well
   if output_hidden_states:
     lowerCamelCase__:				List[str]        =tuple([tf.transpose(UpperCAmelCase_	,			perm=(0, 3, 1, 2)) for h in encoder_outputs[1]])

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

   return TFBaseModelOutputWithPoolingAndNoAttention(
       last_hidden_state=UpperCAmelCase_	,			pooler_output=UpperCAmelCase_	,			hidden_states=hidden_states if output_hidden_states else encoder_outputs.hidden_states	,			)



class        _SCREAMING_SNAKE_CASE						(     __SCREAMING_SNAKE_CASE   ):







 '''simple docstring'''
 lowercase_		=      RegNetConfig
 lowercase_		=      "regnet"
 lowercase_		=      "pixel_values"

 @property
 def 							SCREAMING_SNAKE_CASE_ (self    :       List[Any])	->int:



   '''simple docstring'''



   return {"pixel_values": tf.TensorSpec(shape=(None, self.config.num_channels, 224, 224)	,			dtype=tf.floataa)}



__A     =    R"\n    Parameters:\n    This model is a Tensorflow\n    [tf.keras.layers.Layer](https://www.tensorflow.org/api_docs/python/tf/keras/layers/Layer) sub-class. Use it as a\n    regular Tensorflow Module and refer to the Tensorflow documentation for all matter related to general usage and\n    behavior.\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 [`~TFPreTrainedModel.from_pretrained`] method to load the model weights.\n"

__A     =    R"\n    Args:\n        pixel_values (`tf.Tensor` of shape `(batch_size, num_channels, height, width)`):\n            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See\n            [`ConveNextImageProcessor.__call__`] for details.\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 RegNet 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    :       Optional[Any]	,			UpperCAmelCase_    :       RegNetConfig	,			*UpperCAmelCase_    :       str	,			**UpperCAmelCase_    :       List[str])	->Optional[int]:



   '''simple docstring'''



   super().__init__(UpperCAmelCase_	,			*UpperCAmelCase_	,			**UpperCAmelCase_)
   lowerCamelCase__:				Optional[Any]        =TFRegNetMainLayer(UpperCAmelCase_	,			name="regnet")







 @unpack_inputs
 @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    :       Union[str, Any]	,			UpperCAmelCase_    :       tf.Tensor	,			UpperCAmelCase_    :       Optional[bool] = None	,			UpperCAmelCase_    :       Optional[bool] = None	,			UpperCAmelCase_    :       Dict=False	,			)	->Union[TFBaseModelOutputWithPoolingAndNoAttention, Tuple[tf.Tensor]]:



   '''simple docstring'''



   lowerCamelCase__:				Dict        =(
       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__:				Any        =self.regnet(
       pixel_values=UpperCAmelCase_	,			output_hidden_states=UpperCAmelCase_	,			return_dict=UpperCAmelCase_	,			training=UpperCAmelCase_	,			)
   if not return_dict:
     return (outputs[0],) + outputs[1:]

   return TFBaseModelOutputWithPoolingAndNoAttention(
       last_hidden_state=outputs.last_hidden_state	,			pooler_output=outputs.pooler_output	,			hidden_states=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   ,							)
class        _SCREAMING_SNAKE_CASE						(     __SCREAMING_SNAKE_CASE   ,							__SCREAMING_SNAKE_CASE   ):







 '''simple docstring'''

 def __init__(self    :       Any	,			UpperCAmelCase_    :       RegNetConfig	,			*UpperCAmelCase_    :       List[Any]	,			**UpperCAmelCase_    :       Optional[int])	->List[str]:



   '''simple docstring'''



   super().__init__(UpperCAmelCase_	,			*UpperCAmelCase_	,			**UpperCAmelCase_)
   lowerCamelCase__:				str        =config.num_labels
   lowerCamelCase__:				List[str]        =TFRegNetMainLayer(UpperCAmelCase_	,			name="regnet")
   # classification head
   lowerCamelCase__:				Any        =[
       tf.keras.layers.Flatten(),
       tf.keras.layers.Dense(config.num_labels	,			name="classifier.1") if config.num_labels > 0 else tf.identity,
   ]







 @unpack_inputs
 @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    :       int	,			UpperCAmelCase_    :       tf.Tensor = None	,			UpperCAmelCase_    :       tf.Tensor = None	,			UpperCAmelCase_    :       bool = None	,			UpperCAmelCase_    :       bool = None	,			UpperCAmelCase_    :       List[str]=False	,			)	->Union[TFSequenceClassifierOutput, Tuple[tf.Tensor]]:



   '''simple docstring'''



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

   lowerCamelCase__:				Any        =self.regnet(
       UpperCAmelCase_	,			output_hidden_states=UpperCAmelCase_	,			return_dict=UpperCAmelCase_	,			training=UpperCAmelCase_)

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

   lowerCamelCase__:				Any        =self.classifier[0](UpperCAmelCase_)
   lowerCamelCase__:				str        =self.classifier[1](UpperCAmelCase_)

   lowerCamelCase__:				int        =None if labels is None else self.hf_compute_loss(labels=UpperCAmelCase_	,			logits=UpperCAmelCase_)

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

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







def 					lowerCAmelCase_			(	__a		)					->		str:







  """simple docstring"""





  if isinstance(__a     ,   __a		):
    raise TypeError("'float' object cannot be interpreted as an integer"		)
  if isinstance(__a     ,   __a		):
    raise TypeError("'str' object cannot be interpreted as an integer"		)

  if num == 0:
    return "0b0"

  lowerCamelCase__:				Optional[int]        =False

  if num < 0:
    lowerCamelCase__:				Optional[Any]        =True
    lowerCamelCase__:				List[Any]        =-num

  lowerCamelCase__:				list[int]        =[]
  while num > 0:
    binary.insert(0     ,   num % 2		)
    num >>= 1

  if negative:
    return "-0b" + "".join(str(__a		) for e in binary		)

  return "0b" + "".join(str(__a		) for e in binary		)


if __name__ == "__main__":
     import doctest

     doctest.testmod()

