"""simple docstring"""




import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
from .feature_extraction_wavaveca import WavaVecaFeatureExtractor
from .tokenization_wavaveca import WavaVecaCTCTokenizer
class 						__A							(			SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Any		 =		"Wav2Vec2FeatureExtractor"
     _UpperCamelCase							:      str		 =		"AutoTokenizer"






     def __init__(		self    ,					a__    ,					a__  ):
       super().__init__(a__    ,					a__  )
       _lowerCAmelCase						:	Union[str, Any]        =					self.feature_extractor
       _lowerCAmelCase						:	Union[str, Any]        =					False






     @classmethod
     def    __A  (		cls    ,					a__    ,					**a__  ):
       try:
         return super().from_pretrained(a__    ,					**a__  )
       except OSError:
         warnings.warn(
             F"Loading a tokenizer inside {cls.__name__} from a config that does not"
             """ include a `tokenizer_class` attribute is deprecated and will be """
             """removed in v5. Please add `'tokenizer_class': 'Wav2Vec2CTCTokenizer'`"""
             """ attribute to either your `config.json` or `tokenizer_config.json` """
             """file to suppress this warning: """    ,					a__    ,					)

         _lowerCAmelCase						:	Dict        =					WavaVecaFeatureExtractor.from_pretrained(a__    ,					**a__  )
         _lowerCAmelCase						:	Any        =					WavaVecaCTCTokenizer.from_pretrained(a__    ,					**a__  )

         return cls(feature_extractor=a__    ,					tokenizer=a__  )






     def __call__(		self    ,					*a__    ,					**a__  ):
       # For backward compatibility
       if self._in_target_context_manager:
         return self.current_processor(*a__    ,					**a__  )

       if "raw_speech" in kwargs:
         warnings.warn("""Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."""  )
         _lowerCAmelCase						:	Dict        =					kwargs.pop("""raw_speech"""  )
       else:
         _lowerCAmelCase						:	Union[str, Any]        =					kwargs.pop("""audio"""    ,					a__  )
       _lowerCAmelCase						:	Tuple        =					kwargs.pop("""sampling_rate"""    ,					a__  )
       _lowerCAmelCase						:	Optional[Any]        =					kwargs.pop("""text"""    ,					a__  )
       if len(a__  ) > 0:
         _lowerCAmelCase						:	List[Any]        =					args[0]
         _lowerCAmelCase						:	int        =					args[1:]

       if audio is None and text is None:
         raise ValueError("""You need to specify either an `audio` or `text` input to process."""  )

       if audio is not None:
         _lowerCAmelCase						:	List[str]        =					self.feature_extractor(a__    ,					*a__    ,					sampling_rate=a__    ,					**a__  )
       if text is not None:
         _lowerCAmelCase						:	Optional[Any]        =					self.tokenizer(a__    ,					**a__  )

       if text is None:
         return inputs
       elif audio is None:
         return encodings
       else:
         _lowerCAmelCase						:	Any        =					encodings["""input_ids"""]
         return inputs






     def    __A  (		self    ,					*a__    ,					**a__  ):
       # For backward compatibility
       if self._in_target_context_manager:
         return self.current_processor.pad(*a__    ,					**a__  )

       _lowerCAmelCase						:	List[str]        =					kwargs.pop("""input_features"""    ,					a__  )
       _lowerCAmelCase						:	Optional[int]        =					kwargs.pop("""labels"""    ,					a__  )
       if len(a__  ) > 0:
         _lowerCAmelCase						:	List[Any]        =					args[0]
         _lowerCAmelCase						:	List[str]        =					args[1:]

       if input_features is not None:
         _lowerCAmelCase						:	List[Any]        =					self.feature_extractor.pad(a__    ,					*a__    ,					**a__  )
       if labels is not None:
         _lowerCAmelCase						:	Optional[Any]        =					self.tokenizer.pad(a__    ,					**a__  )

       if labels is None:
         return input_features
       elif input_features is None:
         return labels
       else:
         _lowerCAmelCase						:	Dict        =					labels["""input_ids"""]
         return input_features






     def    __A  (		self    ,					*a__    ,					**a__  ):
       return self.tokenizer.batch_decode(*a__    ,					**a__  )






     def    __A  (		self    ,					*a__    ,					**a__  ):
       return self.tokenizer.decode(*a__    ,					**a__  )






     @contextmanager
     def    __A  (		self  ):
       warnings.warn(
           """`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your """
           """labels by using the argument `text` of the regular `__call__` method (either in the same call as """
           """your audio inputs, or in a separate call."""  )
       _lowerCAmelCase						:	Any        =					True
       _lowerCAmelCase						:	List[Any]        =					self.tokenizer
       yield
       _lowerCAmelCase						:	Any        =					self.feature_extractor
       _lowerCAmelCase						:	Any        =					False





"""simple docstring"""




from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


_a				:		List[Any]	   =       logging.get_logger(__name__)
class 						__A							(			SCREAMING_SNAKE_CASE_   ,     SCREAMING_SNAKE_CASE_		):
     _UpperCamelCase							:      Tuple		 =		"maskformer-swin"

     _UpperCamelCase							:      Union[str, Any]		 =		{
         "num_attention_heads": "num_heads",
         "num_hidden_layers": "num_layers",
     }






     def __init__(		self    ,					a__=224    ,					a__=4    ,					a__=3    ,					a__=96    ,					a__=[2, 2, 6, 2]    ,					a__=[3, 6, 12, 24]    ,					a__=7    ,					a__=4.0    ,					a__=True    ,					a__=0.0    ,					a__=0.0    ,					a__=0.1    ,					a__="gelu"    ,					a__=False    ,					a__=0.0_2    ,					a__=1e-5    ,					a__=None    ,					a__=None    ,					**a__    ,					):
       super().__init__(**a__  )

       _lowerCAmelCase						:	Dict        =					image_size
       _lowerCAmelCase						:	List[str]        =					patch_size
       _lowerCAmelCase						:	Any        =					num_channels
       _lowerCAmelCase						:	int        =					embed_dim
       _lowerCAmelCase						:	Optional[Any]        =					depths
       _lowerCAmelCase						:	List[str]        =					len(a__  )
       _lowerCAmelCase						:	List[Any]        =					num_heads
       _lowerCAmelCase						:	Tuple        =					window_size
       _lowerCAmelCase						:	List[Any]        =					mlp_ratio
       _lowerCAmelCase						:	Optional[Any]        =					qkv_bias
       _lowerCAmelCase						:	int        =					hidden_dropout_prob
       _lowerCAmelCase						:	Union[str, Any]        =					attention_probs_dropout_prob
       _lowerCAmelCase						:	Any        =					drop_path_rate
       _lowerCAmelCase						:	Optional[Any]        =					hidden_act
       _lowerCAmelCase						:	Tuple        =					use_absolute_embeddings
       _lowerCAmelCase						:	str        =					layer_norm_eps
       _lowerCAmelCase						:	Any        =					initializer_range
       # we set the hidden_size attribute in order to make Swin work with VisionEncoderDecoderModel
       # this indicates the channel dimension after the last stage of the model
       _lowerCAmelCase						:	Union[str, Any]        =					int(embed_dim * 2 ** (len(a__  ) - 1)  )
       _lowerCAmelCase						:	int        =					["""stem"""] + [F"stage{idx}" for idx in range(1    ,					len(a__  ) + 1  )]
       _lowerCAmelCase      ,     _lowerCAmelCase						:	int        =					get_aligned_output_features_output_indices(
           out_features=a__    ,					out_indices=a__    ,					stage_names=self.stage_names  )




