
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        lowerCAmelCase__      (   __lowerCamelCase	):
						UpperCamelCase_							: str	=		42







class        lowerCAmelCase__      (   __lowerCamelCase		,	__lowerCamelCase	):

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


								'''simple docstring'''

								super().__init__()

								# pass init params to Encoder
								_UpperCamelCase						    =	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_       ,							)

								_UpperCamelCase						    =	vq_embed_dim if vq_embed_dim is not None else latent_channels

								_UpperCamelCase						    =	nn.Convad(UpperCAmelCase_       ,							UpperCAmelCase_       ,							1				)
								_UpperCamelCase						    =	VectorQuantizer(UpperCAmelCase_       ,							UpperCAmelCase_       ,							beta=0.25       ,							remap=UpperCAmelCase_       ,							sane_index_shape=UpperCAmelCase_				)
								_UpperCamelCase						    =	nn.Convad(UpperCAmelCase_       ,							UpperCAmelCase_       ,							1				)

								# pass init params to Decoder
								_UpperCamelCase						    =	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  A_				(			self       ,							a       ,							a = True				)					->      List[Any]:


								'''simple docstring'''

								_UpperCamelCase						    =	self.encoder(UpperCAmelCase_				)
								_UpperCamelCase						    =	self.quant_conv(UpperCAmelCase_				)

								if not return_dict:
										return (h,)

								return VQEncoderOutput(latents=UpperCAmelCase_				)

						@apply_forward_hook
						def  A_				(			self       ,							a       ,							a = False       ,							a = True				)					->      Union[str, Any]:


								'''simple docstring'''

								if not force_not_quantize:
										_UpperCamelCase						    =	self.quantize(UpperCAmelCase_				)
								else:
										_UpperCamelCase						    =	h
								_UpperCamelCase						    =	self.post_quant_conv(UpperCAmelCase_				)
								_UpperCamelCase						    =	self.decoder(UpperCAmelCase_       ,							quant if self.config.norm_type == """spatial""" else None				)

								if not return_dict:
										return (dec,)

								return DecoderOutput(sample=UpperCAmelCase_				)







						def  A_				(			self       ,							a       ,							a = True				)					->      Tuple:


								'''simple docstring'''

								_UpperCamelCase						    =	sample
								_UpperCamelCase						    =	self.encode(UpperCAmelCase_				).latents
								_UpperCamelCase						    =	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_torch_available


lowerCamelCase__	=							{
    "configuration_mctct": ["MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MCTCTConfig"],
    "feature_extraction_mctct": ["MCTCTFeatureExtractor"],
    "processing_mctct": ["MCTCTProcessor"],
}


try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		lowerCamelCase__	=							[
		    "MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST",
		    "MCTCTForCTC",
		    "MCTCTModel",
		    "MCTCTPreTrainedModel",
		]


if TYPE_CHECKING:
		from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
		from .feature_extraction_mctct import MCTCTFeatureExtractor
		from .processing_mctct import MCTCTProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
		import sys

		lowerCamelCase__	=							_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



