





'''simple docstring'''


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__ (				UpperCAmelCase_    ):

       '''simple docstring'''
       _lowerCamelCase								=42






class     lowerCAmelCase__ (				UpperCAmelCase_      , UpperCAmelCase_    ):

       '''simple docstring'''

       @register_to_config
       def __init__( self					:				List[Any]       ,     a__					:				int = 3       ,     a__					:				int = 3       ,     a__					:				Tuple[str] = ("DownEncoderBlock2D",)       ,     a__					:				Tuple[str] = ("UpDecoderBlock2D",)       ,     a__					:				Tuple[int] = (64,)       ,     a__					:				int = 1       ,     a__					:				str = "silu"       ,     a__					:				int = 3       ,     a__					:				int = 32       ,     a__					:				int = 256       ,     a__					:				int = 32       ,     a__					:				Optional[int] = None       ,     a__					:				float = 0.18_215       ,     a__					:				str = "group"       ,     ):
              super().__init__()

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

              UpperCAmelCase  =						vq_embed_dim if vq_embed_dim is not None else latent_channels

              UpperCAmelCase  =						nn.Convad(a__       ,     a__       ,     1						)
              UpperCAmelCase  =						VectorQuantizer(a__       ,     a__       ,     beta=0.25       ,     remap=a__       ,     sane_index_shape=a__						)
              UpperCAmelCase  =						nn.Convad(a__       ,     a__       ,     1						)

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

       @apply_forward_hook
       def 			__snake_case      ( self					:				Tuple       ,     a__					:				torch.FloatTensor       ,     a__					:				bool = True						):
              UpperCAmelCase  =						self.encoder(a__						)
              UpperCAmelCase  =						self.quant_conv(a__						)

              if not return_dict:
                     return (h,)

              return VQEncoderOutput(latents=a__						)

       @apply_forward_hook
       def 			__snake_case      ( self					:				str       ,     a__					:				torch.FloatTensor       ,     a__					:				bool = False       ,     a__					:				bool = True						):
              # also go through quantization layer
              if not force_not_quantize:
                     UpperCAmelCase,					UpperCAmelCase,					UpperCAmelCase  =						self.quantize(a__						)
              else:
                     UpperCAmelCase  =						h
              UpperCAmelCase  =						self.post_quant_conv(a__						)
              UpperCAmelCase  =						self.decoder(a__       ,     quant if self.config.norm_type == '''spatial''' else None						)

              if not return_dict:
                     return (dec,)

              return DecoderOutput(sample=a__						)



       def 			__snake_case      ( self					:				List[Any]       ,     a__					:				torch.FloatTensor       ,     a__					:				bool = True						):
              UpperCAmelCase  =						sample
              UpperCAmelCase  =						self.encode(a__						).latents
              UpperCAmelCase  =						self.decode(a__						).sample

              if not return_dict:
                     return (dec,)

              return DecoderOutput(sample=a__						)






# Lint as: python3
# pylint: enable=line-too-long
# pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position

a			:			Dict												=					'''2.13.1'''

import platform

import pyarrow
from packaging import version


if version.parse(platform.python_version()) < version.parse('''3.7'''):
	raise ImportWarning(
	    '''To use `datasets`, Python>=3.7 is required, and the current version of Python doesn\'t match this condition.'''
	)

if version.parse(pyarrow.__version__).major < 8:
	raise ImportWarning(
	    '''To use `datasets`, the module `pyarrow>=8.0.0` is required, and the current version of `pyarrow` doesn\'t match this condition.\n'''
	    '''If you are running this in a Google Colab, you should probably just restart the runtime to use the right version of `pyarrow`.'''
	)

del platform
del pyarrow
del version

from .arrow_dataset import Dataset
from .arrow_reader import ReadInstruction
from .builder import ArrowBasedBuilder, BeamBasedBuilder, BuilderConfig, DatasetBuilder, GeneratorBasedBuilder
from .combine import concatenate_datasets, interleave_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .download import *
from .features import *
from .fingerprint import disable_caching, enable_caching, is_caching_enabled, set_caching_enabled
from .info import DatasetInfo, MetricInfo
from .inspect import (
    get_dataset_config_info,
    get_dataset_config_names,
    get_dataset_infos,
    get_dataset_split_names,
    inspect_dataset,
    inspect_metric,
    list_datasets,
    list_metrics,
)
from .iterable_dataset import IterableDataset
from .load import load_dataset, load_dataset_builder, load_from_disk, load_metric
from .metric import Metric
from .splits import (
    NamedSplit,
    NamedSplitAll,
    Split,
    SplitBase,
    SplitDict,
    SplitGenerator,
    SplitInfo,
    SubSplitInfo,
    percent,
)
from .tasks import *
from .utils import *
from .utils import logging


# deprecated modules
from datasets import arrow_dataset as _arrow_dataset  # isort:skip
from datasets import utils as _utils  # isort:skip
from datasets.utils import download_manager as _deprecated_download_manager  # isort:skip

a			:			Optional[int]												=					concatenate_datasets
a			:			List[Any]												=					DownloadConfig
a			:			List[Any]												=					DownloadManager
a			:			str												=					DownloadMode
a			:			int												=					DownloadConfig
a			:			List[str]												=					DownloadMode
a			:			Optional[int]												=					DownloadManager

del _arrow_dataset, _utils, _deprecated_download_manager


