

from dataclasses import dataclass
from typing import Optional, Tuple, Union

import torch
import torch.nn as nn

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, apply_forward_hook
from .modeling_utils import ModelMixin
from .vae import Decoder, DecoderOutput, Encoder, VectorQuantizer


@dataclass
class SCREAMING_SNAKE_CASE	(		__snake_case				):






			"""simple docstring"""




			__A    	=	42







class SCREAMING_SNAKE_CASE	(		__snake_case				,    __snake_case				):






			"""simple docstring"""




			@register_to_config
			def __init__(     self			,					__UpperCamelCase = 3			,					__UpperCamelCase = 3			,					__UpperCamelCase = ("DownEncoderBlock2D",)			,					__UpperCamelCase = ("UpDecoderBlock2D",)			,					__UpperCamelCase = (64,)			,					__UpperCamelCase = 1			,					__UpperCamelCase = "silu"			,					__UpperCamelCase = 3			,					__UpperCamelCase = 32			,					__UpperCamelCase = 2_56			,					__UpperCamelCase = 32			,					__UpperCamelCase = None			,					__UpperCamelCase = 0.1_8215			,					__UpperCamelCase = "group"			,					):

				"""simple docstring"""


				super().__init__()

				# pass init params to Encoder
				snake_case_   		=			Encoder(
				    in_channels=__UpperCamelCase			,					out_channels=__UpperCamelCase			,					down_block_types=__UpperCamelCase			,					block_out_channels=__UpperCamelCase			,					layers_per_block=__UpperCamelCase			,					act_fn=__UpperCamelCase			,					norm_num_groups=__UpperCamelCase			,					double_z=__UpperCamelCase			,					)

				snake_case_   		=			vq_embed_dim if vq_embed_dim is not None else latent_channels

				snake_case_   		=			nn.Convad(__UpperCamelCase			,					__UpperCamelCase			,					1				)
				snake_case_   		=			VectorQuantizer(__UpperCamelCase			,					__UpperCamelCase			,					beta=0.25			,					remap=__UpperCamelCase			,					sane_index_shape=__UpperCamelCase				)
				snake_case_   		=			nn.Convad(__UpperCamelCase			,					__UpperCamelCase			,					1				)

				# pass init params to Decoder
				snake_case_   		=			Decoder(
				    in_channels=__UpperCamelCase			,					out_channels=__UpperCamelCase			,					up_block_types=__UpperCamelCase			,					block_out_channels=__UpperCamelCase			,					layers_per_block=__UpperCamelCase			,					act_fn=__UpperCamelCase			,					norm_num_groups=__UpperCamelCase			,					norm_type=__UpperCamelCase			,					)


			@apply_forward_hook
			def       __lowerCAmelCase			(     self			,					__UpperCamelCase			,					__UpperCamelCase = True				):

				"""simple docstring"""


				snake_case_   		=			self.encoder(__UpperCamelCase				)
				snake_case_   		=			self.quant_conv(__UpperCamelCase				)

				if not return_dict:
					return (h,)

				return VQEncoderOutput(latents=__UpperCamelCase				)


			@apply_forward_hook
			def       __lowerCAmelCase			(     self			,					__UpperCamelCase			,					__UpperCamelCase = False			,					__UpperCamelCase = True				):

				"""simple docstring"""


				if not force_not_quantize:
					snake_case_		,							snake_case_		,							snake_case_   		=			self.quantize(__UpperCamelCase				)
				else:
					snake_case_   		=			h
				snake_case_   		=			self.post_quant_conv(__UpperCamelCase				)
				snake_case_   		=			self.decoder(__UpperCamelCase			,					quant if self.config.norm_type == 'spatial' else None				)

				if not return_dict:
					return (dec,)

				return DecoderOutput(sample=__UpperCamelCase				)







			def       __lowerCAmelCase			(     self			,					__UpperCamelCase			,					__UpperCamelCase = True				):

				"""simple docstring"""


				snake_case_   		=			sample
				snake_case_   		=			self.encode(__UpperCamelCase				).latents
				snake_case_   		=			self.decode(__UpperCamelCase				).sample

				if not return_dict:
					return (dec,)

				return DecoderOutput(sample=__UpperCamelCase				)



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_speech_available,
    is_tf_available,
    is_torch_available,
)


A									=  {
    'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Speech2TextConfig'],
    'processing_speech_to_text': ['Speech2TextProcessor'],
}

try:
		if not is_sentencepiece_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		A									=  ['Speech2TextTokenizer']

try:
		if not is_speech_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		A									=  ['Speech2TextFeatureExtractor']

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		A									=  [
		    'TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'TFSpeech2TextForConditionalGeneration',
		    'TFSpeech2TextModel',
		    'TFSpeech2TextPreTrainedModel',
		]

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		A									=  [
		    'SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'Speech2TextForConditionalGeneration',
		    'Speech2TextModel',
		    'Speech2TextPreTrainedModel',
		]


if TYPE_CHECKING:
		from .configuration_speech_to_text import SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextConfig
		from .processing_speech_to_text import SpeechaTextProcessor

		try:
				if not is_sentencepiece_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_speech_to_text import SpeechaTextTokenizer

		try:
				if not is_speech_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .feature_extraction_speech_to_text import SpeechaTextFeatureExtractor

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_speech_to_text import (
				    TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFSpeechaTextForConditionalGeneration,
				    TFSpeechaTextModel,
				    TFSpeechaTextPreTrainedModel,
				)

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_speech_to_text import (
				    SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    SpeechaTextForConditionalGeneration,
				    SpeechaTextModel,
				    SpeechaTextPreTrainedModel,
				)

else:
		import sys

		A									=  _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
