
"""simple docstring"""




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		:       List[Any]     						=       logging.get_logger(__name__)

# General docstring
a		:       Tuple     						=       'RegNetConfig'

# Base docstring
a		:       str     						=       'facebook/regnet-y-040'
a		:       Any     						=       [1, 10_88, 7, 7]

# Image classification docstring
a		:       Tuple     						=       'facebook/regnet-y-040'
a		:       int     						=       'tabby, tabby cat'

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







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



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = 3     ,				__SCREAMING_SNAKE_CASE = 1     ,				__SCREAMING_SNAKE_CASE = 1     ,				__SCREAMING_SNAKE_CASE = "relu"     ,				**__SCREAMING_SNAKE_CASE     ,				)		->     List[Any]:







         """simple docstring"""



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




     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE   )		->     Tuple:







         """simple docstring"""



         a__		=			self.convolution(self.padding(__SCREAMING_SNAKE_CASE   )   )
         a__		=			self.normalization(__SCREAMING_SNAKE_CASE   )
         a__		=			self.activation(__SCREAMING_SNAKE_CASE   )
         return hidden_state







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



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				**__SCREAMING_SNAKE_CASE   )		->     Dict:







         """simple docstring"""



         super().__init__(**__SCREAMING_SNAKE_CASE   )
         a__		=			config.num_channels
         a__		=			TFRegNetConvLayer(
             out_channels=config.embedding_size     ,				kernel_size=3     ,				stride=2     ,				activation=config.hidden_act     ,				name='embedder'     ,				)




     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE   )		->     Optional[Any]:







         """simple docstring"""



         a__		=			shape_list(__SCREAMING_SNAKE_CASE   )[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)
         a__		=			tf.transpose(__SCREAMING_SNAKE_CASE     ,				perm=(0, 2, 3, 1)   )
         a__		=			self.embedder(__SCREAMING_SNAKE_CASE   )
         return hidden_state







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



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = 2     ,				**__SCREAMING_SNAKE_CASE   )		->     Any:







         """simple docstring"""



         super().__init__(**__SCREAMING_SNAKE_CASE   )
         a__		=			tf.keras.layers.ConvaD(
             filters=__SCREAMING_SNAKE_CASE     ,				kernel_size=1     ,				strides=__SCREAMING_SNAKE_CASE     ,				use_bias=__SCREAMING_SNAKE_CASE     ,				name='convolution'   )
         a__		=			tf.keras.layers.BatchNormalization(epsilon=1e-5     ,				momentum=0.9     ,				name='normalization'   )




     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = False   )		->     tf.Tensor:







         """simple docstring"""



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







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



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				**__SCREAMING_SNAKE_CASE   )		->     List[Any]:







         """simple docstring"""



         super().__init__(**__SCREAMING_SNAKE_CASE   )
         a__		=			tf.keras.layers.GlobalAveragePoolingaD(keepdims=__SCREAMING_SNAKE_CASE     ,				name='pooler'   )
         a__		=			[
             tf.keras.layers.ConvaD(filters=__SCREAMING_SNAKE_CASE     ,				kernel_size=1     ,				activation='relu'     ,				name='attention.0'   ),
             tf.keras.layers.ConvaD(filters=__SCREAMING_SNAKE_CASE     ,				kernel_size=1     ,				activation='sigmoid'     ,				name='attention.2'   ),
         ]




     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE   )		->     Optional[int]:







         """simple docstring"""



         a__		=			self.pooler(__SCREAMING_SNAKE_CASE   )
         for layer_module in self.attention:
             a__		=			layer_module(__SCREAMING_SNAKE_CASE   )
         a__		=			hidden_state * pooled
         return hidden_state







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



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = 1     ,				**__SCREAMING_SNAKE_CASE   )		->     Dict:







         """simple docstring"""



         super().__init__(**__SCREAMING_SNAKE_CASE   )
         a__		=			in_channels != out_channels or stride != 1
         a__		=			max(1     ,				out_channels // config.groups_width   )
         a__		=			(
             TFRegNetShortCut(__SCREAMING_SNAKE_CASE     ,				stride=__SCREAMING_SNAKE_CASE     ,				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.
         a__		=			[
             TFRegNetConvLayer(__SCREAMING_SNAKE_CASE     ,				kernel_size=1     ,				activation=config.hidden_act     ,				name='layer.0'   ),
             TFRegNetConvLayer(
                 __SCREAMING_SNAKE_CASE     ,				stride=__SCREAMING_SNAKE_CASE     ,				groups=__SCREAMING_SNAKE_CASE     ,				activation=config.hidden_act     ,				name='layer.1'   ),
             TFRegNetConvLayer(__SCREAMING_SNAKE_CASE     ,				kernel_size=1     ,				activation=__SCREAMING_SNAKE_CASE     ,				name='layer.2'   ),
         ]
         a__		=			ACTaFN[config.hidden_act]




     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE   )		->     Tuple:







         """simple docstring"""



         a__		=			hidden_state
         for layer_module in self.layers:
             a__		=			layer_module(__SCREAMING_SNAKE_CASE   )
         a__		=			self.shortcut(__SCREAMING_SNAKE_CASE   )
         hidden_state += residual
         a__		=			self.activation(__SCREAMING_SNAKE_CASE   )
         return hidden_state







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



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = 1     ,				**__SCREAMING_SNAKE_CASE   )		->     str:







         """simple docstring"""



         super().__init__(**__SCREAMING_SNAKE_CASE   )
         a__		=			in_channels != out_channels or stride != 1
         a__		=			max(1     ,				out_channels // config.groups_width   )
         a__		=			(
             TFRegNetShortCut(__SCREAMING_SNAKE_CASE     ,				stride=__SCREAMING_SNAKE_CASE     ,				name='shortcut'   )
             if should_apply_shortcut
             else tf.keras.layers.Activation('linear'     ,				name='shortcut'   )
         )
         a__		=			[
             TFRegNetConvLayer(__SCREAMING_SNAKE_CASE     ,				kernel_size=1     ,				activation=config.hidden_act     ,				name='layer.0'   ),
             TFRegNetConvLayer(
                 __SCREAMING_SNAKE_CASE     ,				stride=__SCREAMING_SNAKE_CASE     ,				groups=__SCREAMING_SNAKE_CASE     ,				activation=config.hidden_act     ,				name='layer.1'   ),
             TFRegNetSELayer(__SCREAMING_SNAKE_CASE     ,				reduced_channels=int(round(in_channels / 4   )   )     ,				name='layer.2'   ),
             TFRegNetConvLayer(__SCREAMING_SNAKE_CASE     ,				kernel_size=1     ,				activation=__SCREAMING_SNAKE_CASE     ,				name='layer.3'   ),
         ]
         a__		=			ACTaFN[config.hidden_act]




     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE   )		->     str:







         """simple docstring"""



         a__		=			hidden_state
         for layer_module in self.layers:
             a__		=			layer_module(__SCREAMING_SNAKE_CASE   )
         a__		=			self.shortcut(__SCREAMING_SNAKE_CASE   )
         hidden_state += residual
         a__		=			self.activation(__SCREAMING_SNAKE_CASE   )
         return hidden_state







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



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = 2     ,				__SCREAMING_SNAKE_CASE = 2     ,				**__SCREAMING_SNAKE_CASE   )		->     Tuple:







         """simple docstring"""



         super().__init__(**__SCREAMING_SNAKE_CASE   )

         a__		=			TFRegNetXLayer if config.layer_type == 'x' else TFRegNetYLayer
         a__		=			[
             # 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     ,				name='layers.0'   ),
             *[layer(__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				name=f'layers.{i+1}'   ) for i in range(depth - 1   )],
         ]




     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE   )		->     Tuple:







         """simple docstring"""



         for layer_module in self.layers:
             a__		=			layer_module(__SCREAMING_SNAKE_CASE   )
         return hidden_state







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



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				**__SCREAMING_SNAKE_CASE   )		->     str:







         """simple docstring"""



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




     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = False     ,				__SCREAMING_SNAKE_CASE = True   )		->     TFBaseModelOutputWithNoAttention:







         """simple docstring"""



         a__		=			() if output_hidden_states else None

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

             a__		=			stage_module(__SCREAMING_SNAKE_CASE   )

         if output_hidden_states:
             a__		=			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=__SCREAMING_SNAKE_CASE     ,				hidden_states=__SCREAMING_SNAKE_CASE   )







@keras_serializable
class     lowercase(tf.keras.layers.Layer       ):
     __snake_case:	List[str]						=     RegNetConfig



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				**__SCREAMING_SNAKE_CASE   )		->     Dict:







         """simple docstring"""



         super().__init__(**__SCREAMING_SNAKE_CASE   )
         a__		=			config
         a__		=			TFRegNetEmbeddings(__SCREAMING_SNAKE_CASE     ,				name='embedder'   )
         a__		=			TFRegNetEncoder(__SCREAMING_SNAKE_CASE     ,				name='encoder'   )
         a__		=			tf.keras.layers.GlobalAveragePoolingaD(keepdims=__SCREAMING_SNAKE_CASE     ,				name='pooler'   )




     @unpack_inputs
     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = False     ,				)		->     TFBaseModelOutputWithPoolingAndNoAttention:







         """simple docstring"""



         a__		=			(
             output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
         )
         a__		=			return_dict if return_dict is not None else self.config.use_return_dict

         a__		=			self.embedder(__SCREAMING_SNAKE_CASE     ,				training=__SCREAMING_SNAKE_CASE   )

         a__		=			self.encoder(
             __SCREAMING_SNAKE_CASE     ,				output_hidden_states=__SCREAMING_SNAKE_CASE     ,				return_dict=__SCREAMING_SNAKE_CASE     ,				training=__SCREAMING_SNAKE_CASE   )

         a__		=			encoder_outputs[0]
         a__		=			self.pooler(__SCREAMING_SNAKE_CASE   )

         # Change to NCHW output format have uniformity in the modules
         a__		=			tf.transpose(__SCREAMING_SNAKE_CASE     ,				perm=(0, 3, 1, 2)   )
         a__		=			tf.transpose(__SCREAMING_SNAKE_CASE     ,				perm=(0, 3, 1, 2)   )

         # Change the other hidden state outputs to NCHW as well
         if output_hidden_states:
             a__		=			tuple([tf.transpose(__SCREAMING_SNAKE_CASE     ,				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=__SCREAMING_SNAKE_CASE     ,				pooler_output=__SCREAMING_SNAKE_CASE     ,				hidden_states=hidden_states if output_hidden_states else encoder_outputs.hidden_states     ,				)







class     lowercase(_lowercase       ):
     __snake_case:	List[Any]						=     RegNetConfig
     __snake_case:	Optional[Any]						=     'regnet'
     __snake_case:	int						=     'pixel_values'



     @property
     def 			lowercase__  (							self   )		->     Dict:







         """simple docstring"""



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




a		:       List[str]     						=       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		:       int     						=       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.'    ,						_lowercase    ,						)
class     lowercase(_lowercase       ):



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				*__SCREAMING_SNAKE_CASE     ,				**__SCREAMING_SNAKE_CASE   )		->     List[Any]:







         """simple docstring"""



         super().__init__(__SCREAMING_SNAKE_CASE     ,				*__SCREAMING_SNAKE_CASE     ,				**__SCREAMING_SNAKE_CASE   )
         a__		=			TFRegNetMainLayer(__SCREAMING_SNAKE_CASE     ,				name='regnet'   )




     @unpack_inputs
     @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 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE=False     ,				)		->     Union[TFBaseModelOutputWithPoolingAndNoAttention, Tuple[tf.Tensor]]:







         """simple docstring"""



         a__		=			(
             output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
         )
         a__		=			return_dict if return_dict is not None else self.config.use_return_dict

         a__		=			self.regnet(
             pixel_values=__SCREAMING_SNAKE_CASE     ,				output_hidden_states=__SCREAMING_SNAKE_CASE     ,				return_dict=__SCREAMING_SNAKE_CASE     ,				training=__SCREAMING_SNAKE_CASE     ,				)
         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    '    ,						_lowercase    ,						)
class     lowercase(_lowercase    ,						_lowercase       ):



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				*__SCREAMING_SNAKE_CASE     ,				**__SCREAMING_SNAKE_CASE   )		->     str:







         """simple docstring"""



         super().__init__(__SCREAMING_SNAKE_CASE     ,				*__SCREAMING_SNAKE_CASE     ,				**__SCREAMING_SNAKE_CASE   )
         a__		=			config.num_labels
         a__		=			TFRegNetMainLayer(__SCREAMING_SNAKE_CASE     ,				name='regnet'   )
         # classification head
         a__		=			[
             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(__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 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE=False     ,				)		->     Union[TFSequenceClassifierOutput, Tuple[tf.Tensor]]:







         """simple docstring"""



         a__		=			(
             output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
         )
         a__		=			return_dict if return_dict is not None else self.config.use_return_dict

         a__		=			self.regnet(
             __SCREAMING_SNAKE_CASE     ,				output_hidden_states=__SCREAMING_SNAKE_CASE     ,				return_dict=__SCREAMING_SNAKE_CASE     ,				training=__SCREAMING_SNAKE_CASE   )

         a__		=			outputs.pooler_output if return_dict else outputs[1]

         a__		=			self.classifier[0](__SCREAMING_SNAKE_CASE   )
         a__		=			self.classifier[1](__SCREAMING_SNAKE_CASE   )

         a__		=			None if labels is None else self.hf_compute_loss(labels=__SCREAMING_SNAKE_CASE     ,				logits=__SCREAMING_SNAKE_CASE   )

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

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




"""simple docstring"""




import shutil
import tempfile
import unittest

from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast
from transformers.testing_utils import require_sentencepiece, require_torchaudio

from .test_feature_extraction_clap import floats_list







@require_torchaudio
@require_sentencepiece
class     lowercase(unittest.TestCase       ):



     def 			lowercase__  (							self   )		->     List[str]:







         """simple docstring"""



         a__		=			'laion/clap-htsat-unfused'
         a__		=			tempfile.mkdtemp()



     def 			lowercase__  (							self     ,				**__SCREAMING_SNAKE_CASE   )		->     Optional[Any]:







         """simple docstring"""



         return RobertaTokenizer.from_pretrained(self.checkpoint     ,				**__SCREAMING_SNAKE_CASE   )



     def 			lowercase__  (							self     ,				**__SCREAMING_SNAKE_CASE   )		->     Tuple:







         """simple docstring"""



         return ClapFeatureExtractor.from_pretrained(self.checkpoint     ,				**__SCREAMING_SNAKE_CASE   )



     def 			lowercase__  (							self   )		->     Tuple:







         """simple docstring"""



         shutil.rmtree(self.tmpdirname   )



     def 			lowercase__  (							self   )		->     Optional[int]:







         """simple docstring"""



         a__		=			self.get_tokenizer()
         a__		=			self.get_feature_extractor()

         a__		=			ClapProcessor(tokenizer=__SCREAMING_SNAKE_CASE     ,				feature_extractor=__SCREAMING_SNAKE_CASE   )

         processor.save_pretrained(self.tmpdirname   )
         a__		=			ClapProcessor.from_pretrained(self.tmpdirname   )

         self.assertEqual(processor.tokenizer.get_vocab()     ,				tokenizer.get_vocab()   )
         self.assertIsInstance(processor.tokenizer     ,				__SCREAMING_SNAKE_CASE   )

         self.assertEqual(processor.feature_extractor.to_json_string()     ,				feature_extractor.to_json_string()   )
         self.assertIsInstance(processor.feature_extractor     ,				__SCREAMING_SNAKE_CASE   )



     def 			lowercase__  (							self   )		->     Optional[int]:







         """simple docstring"""



         a__		=			ClapProcessor(tokenizer=self.get_tokenizer()     ,				feature_extractor=self.get_feature_extractor()   )
         processor.save_pretrained(self.tmpdirname   )

         a__		=			self.get_tokenizer(bos_token='(BOS)'     ,				eos_token='(EOS)'   )
         a__		=			self.get_feature_extractor(do_normalize=__SCREAMING_SNAKE_CASE     ,				padding_value=1.0   )

         a__		=			ClapProcessor.from_pretrained(
             self.tmpdirname     ,				bos_token='(BOS)'     ,				eos_token='(EOS)'     ,				do_normalize=__SCREAMING_SNAKE_CASE     ,				padding_value=1.0   )

         self.assertEqual(processor.tokenizer.get_vocab()     ,				tokenizer_add_kwargs.get_vocab()   )
         self.assertIsInstance(processor.tokenizer     ,				__SCREAMING_SNAKE_CASE   )

         self.assertEqual(processor.feature_extractor.to_json_string()     ,				feature_extractor_add_kwargs.to_json_string()   )
         self.assertIsInstance(processor.feature_extractor     ,				__SCREAMING_SNAKE_CASE   )



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







         """simple docstring"""



         a__		=			self.get_feature_extractor()
         a__		=			self.get_tokenizer()

         a__		=			ClapProcessor(tokenizer=__SCREAMING_SNAKE_CASE     ,				feature_extractor=__SCREAMING_SNAKE_CASE   )

         a__		=			floats_list((3, 1_0_0_0)   )

         a__		=			feature_extractor(__SCREAMING_SNAKE_CASE     ,				return_tensors='np'   )
         a__		=			processor(audios=__SCREAMING_SNAKE_CASE     ,				return_tensors='np'   )

         for key in input_feat_extract.keys():
             self.assertAlmostEqual(input_feat_extract[key].sum()     ,				input_processor[key].sum()     ,				delta=1e-2   )



     def 			lowercase__  (							self   )		->     Tuple:







         """simple docstring"""



         a__		=			self.get_feature_extractor()
         a__		=			self.get_tokenizer()

         a__		=			ClapProcessor(tokenizer=__SCREAMING_SNAKE_CASE     ,				feature_extractor=__SCREAMING_SNAKE_CASE   )

         a__		=			'This is a test string'

         a__		=			processor(text=__SCREAMING_SNAKE_CASE   )

         a__		=			tokenizer(__SCREAMING_SNAKE_CASE   )

         for key in encoded_tok.keys():
             self.assertListEqual(encoded_tok[key]     ,				encoded_processor[key]   )



     def 			lowercase__  (							self   )		->     Dict:







         """simple docstring"""



         a__		=			self.get_feature_extractor()
         a__		=			self.get_tokenizer()

         a__		=			ClapProcessor(tokenizer=__SCREAMING_SNAKE_CASE     ,				feature_extractor=__SCREAMING_SNAKE_CASE   )

         a__		=			[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

         a__		=			processor.batch_decode(__SCREAMING_SNAKE_CASE   )
         a__		=			tokenizer.batch_decode(__SCREAMING_SNAKE_CASE   )

         self.assertListEqual(__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE   )




     def 			lowercase__  (							self   )		->     List[Any]:







         """simple docstring"""



         a__		=			self.get_feature_extractor()
         a__		=			self.get_tokenizer()

         a__		=			ClapProcessor(tokenizer=__SCREAMING_SNAKE_CASE     ,				feature_extractor=__SCREAMING_SNAKE_CASE   )

         self.assertListEqual(
             processor.model_input_names[2:]     ,				feature_extractor.model_input_names     ,				msg='`processor` and `feature_extractor` model input names do not match'     ,				)


