



import itertools
import os
from collections import Counter, defaultdict
from concurrent.futures import ThreadPoolExecutor, as_completed

import numpy as np

import datasets

from .execute import check_correctness


__lowerCamelCase     :							Union[str, Any]  							=				"\\n@misc{chen2021evaluating,\n      title={Evaluating Large Language Models Trained on Code},\n      author={Mark Chen and Jerry Tworek and Heewoo Jun and Qiming Yuan \\nand Henrique Ponde de Oliveira Pinto and Jared Kaplan and Harri Edwards \\nand Yuri Burda and Nicholas Joseph and Greg Brockman and Alex Ray \\nand Raul Puri and Gretchen Krueger and Michael Petrov and Heidy Khlaaf \\nand Girish Sastry and Pamela Mishkin and Brooke Chan and Scott Gray \\nand Nick Ryder and Mikhail Pavlov and Alethea Power and Lukasz Kaiser \\nand Mohammad Bavarian and Clemens Winter and Philippe Tillet \\nand Felipe Petroski Such and Dave Cummings and Matthias Plappert \\nand Fotios Chantzis and Elizabeth Barnes and Ariel Herbert-Voss \\nand William Hebgen Guss and Alex Nichol and Alex Paino and Nikolas Tezak \\nand Jie Tang and Igor Babuschkin and Suchir Balaji and Shantanu Jain \\nand William Saunders and Christopher Hesse and Andrew N. Carr \\nand Jan Leike and Josh Achiam and Vedant Misra and Evan Morikawa \\nand Alec Radford and Matthew Knight and Miles Brundage and Mira Murati \\nand Katie Mayer and Peter Welinder and Bob McGrew and Dario Amodei \\nand Sam McCandlish and Ilya Sutskever and Wojciech Zaremba},\n      year={2021},\n      eprint={2107.03374},\n      archivePrefix={arXiv},\n      primaryClass={cs.LG}\n}\n"

__lowerCamelCase     :							List[str]  							=				"\\nThis metric implements the evaluation harness for the HumanEval problem solving dataset\ndescribed in the paper \"Evaluating Large Language Models Trained on Code\"\n(https://arxiv.org/abs/2107.03374).\n"


__lowerCamelCase     :							Union[str, Any]  							=				"\nCalculates how good are predictions given some references, using certain scores\nArgs:\n    predictions: list of candidates to evaluate. Each candidates should be a list\n        of strings with several code candidates to solve the problem.\n    references: a list with a test for each prediction. Each test should evaluate the\n        correctness of a code candidate.\n    k: number of code candidates to consider in the evaluation (Default: [1, 10, 100])\n    num_workers: number of workers used to evaluate the canidate programs (Default: 4).\n    timeout:\nReturns:\n    pass_at_k: dict with pass rates for each k\n    results: dict with granular results of each unittest\nExamples:\n    >>> code_eval = datasets.load_metric(\"code_eval\")\n    >>> test_cases = [\"assert add(2,3)==5\"]\n    >>> candidates = [[\"def add(a,b): return a*b\", \"def add(a, b): return a+b\"]]\n    >>> pass_at_k, results = code_eval.compute(references=test_cases, predictions=candidates, k=[1, 2])\n    >>> print(pass_at_k)\n    {'pass@1': 0.5, 'pass@2': 1.0}\n"


__lowerCamelCase     :							Dict  							=				"\n################################################################################\n                                  !!!WARNING!!!\n################################################################################\nThe \"code_eval\" metric executes untrusted model-generated code in Python.\nAlthough it is highly unlikely that model-generated code will do something\novertly malicious in response to this test suite, model-generated code may act\ndestructively due to a lack of model capability or alignment.\nUsers are strongly encouraged to sandbox this evaluation suite so that it\ndoes not perform destructive actions on their host or network. For more\ninformation on how OpenAI sandboxes its code, see the paper \"Evaluating Large\nLanguage Models Trained on Code\" (https://arxiv.org/abs/2107.03374).\n\nOnce you have read this disclaimer and taken appropriate precautions,\nset the environment variable HF_ALLOW_CODE_EVAL=\"1\". Within Python you can to this\nwith:\n\n>>> import os\n>>> os.environ[\"HF_ALLOW_CODE_EVAL\"] = \"1\"\n\n################################################################################\\n"

__lowerCamelCase     :							Optional[Any]  							=				"The MIT License\n\nCopyright (c) OpenAI (https://openai.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE."





@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION,  _KWARGS_DESCRIPTION						)
class  __magic_name__   (							datasets.Metric						):






		def SCREAMING_SNAKE_CASE_			(						self      :     Any      )				->					List[str]:
								'''simple docstring'''







								return datasets.MetricInfo(
								    # This is the description that will appear on the metrics page.
								    description=_DESCRIPTION				,		citation=_CITATION				,		inputs_description=_KWARGS_DESCRIPTION				,		features=datasets.Features(
								        {
								            "predictions": datasets.Sequence(datasets.Value("string"      )      ),
								            "references": datasets.Value("string"      ),
								        }      )				,		homepage="https://github.com/openai/human-eval"				,		codebase_urls=["https://github.com/openai/human-eval"]				,		reference_urls=["https://github.com/openai/human-eval"]				,		license=_LICENSE				,		)







		def SCREAMING_SNAKE_CASE_			(						self      :     List[str]				,		UpperCamelCase__      :     List[str]				,		UpperCamelCase__      :     List[str]				,		UpperCamelCase__      :     Union[str, Any]=[1, 10, 1_00]				,		UpperCamelCase__      :     List[Any]=4				,		UpperCamelCase__      :     Any=3.0      )				->					List[Any]:
								'''simple docstring'''







								if os.getenv("HF_ALLOW_CODE_EVAL"				,		0      ) != "1":
														raise ValueError(_WARNING      )

								if os.name == "nt":
														raise NotImplementedError("This metric is currently not supported on Windows."      )

								with ThreadPoolExecutor(max_workers=UpperCamelCase__      ) as executor:
														UpperCAmelCase         =     []
														UpperCAmelCase         =     Counter()
														UpperCAmelCase         =     0
														UpperCAmelCase         =     defaultdict(UpperCamelCase__      )

														for task_id, (candidates, test_case) in enumerate(zip(UpperCamelCase__				,		UpperCamelCase__      )      ):
																				for candidate in candidates:
																										UpperCAmelCase         =     candidate + "\n" + test_case
																										UpperCAmelCase         =     (test_program, timeout, task_id, completion_id[task_id])
																										UpperCAmelCase         =     executor.submit(UpperCamelCase__				,		*UpperCamelCase__      )
																										futures.append(UpperCamelCase__      )
																										completion_id[task_id] += 1
																										n_samples += 1

														for future in as_completed(UpperCamelCase__      ):
																				UpperCAmelCase         =     future.result()
																				results[result["task_id"]].append((result["completion_id"], result)      )

								UpperCAmelCase       ,		UpperCAmelCase         =     [], []
								for result in results.values():
														result.sort()
														UpperCAmelCase         =     [r[1]["passed"] for r in result]
														total.append(len(UpperCamelCase__      )      )
														correct.append(sum(UpperCamelCase__      )      )
								UpperCAmelCase         =     np.array(UpperCamelCase__      )
								UpperCAmelCase         =     np.array(UpperCamelCase__      )

								UpperCAmelCase         =     k
								UpperCAmelCase         =     {F'pass@{k}': estimate_pass_at_k(UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__      ).mean() for k in ks if (total >= k).all()}

								return pass_at_k, results

def    lowerCamelCase_(lowerCamelCase_    ,   lowerCamelCase_    ,   lowerCamelCase_    ) ->       Dict:

						def estimator(lowerCamelCase_    ,   lowerCamelCase_    ,   lowerCamelCase_    ) -> float:
												if n - c < k:
																		return 1.0
												return 1.0 - np.prod(1.0 - k / np.arange(n - c + 1    ,   n + 1    )    )

						if isinstance(lowerCamelCase_    ,   lowerCamelCase_    ):
												UpperCAmelCase         =     itertools.repeat(lowerCamelCase_    ,   len(lowerCamelCase_    )    )
						else:
												assert len(lowerCamelCase_    ) == len(lowerCamelCase_    )
												UpperCAmelCase         =     iter(lowerCamelCase_    )

						return np.array([estimator(int(lowerCamelCase_    )    ,   int(lowerCamelCase_    )    ,   lowerCamelCase_    ) for n, c in zip(lowerCamelCase_    ,   lowerCamelCase_    )]    )








from dataclasses import dataclass
from typing import Dict, 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 .attention_processor import AttentionProcessor, AttnProcessor
from .modeling_utils import ModelMixin
from .vae import Decoder, DecoderOutput, DiagonalGaussianDistribution, Encoder





@dataclass
class  __magic_name__   (							A__						):
		lowercase      :       "DiagonalGaussianDistribution"





class  __magic_name__   (							A__,  A__						):
		lowercase      :       Union[str, Any]          =True






		@register_to_config
		def __init__(						self      :     List[str]				,		UpperCamelCase__      :     int = 3				,		UpperCamelCase__      :     int = 3				,		UpperCamelCase__      :     Tuple[str] = ("DownEncoderBlock2D",)				,		UpperCamelCase__      :     Tuple[str] = ("UpDecoderBlock2D",)				,		UpperCamelCase__      :     Tuple[int] = (64,)				,		UpperCamelCase__      :     int = 1				,		UpperCamelCase__      :     str = "silu"				,		UpperCamelCase__      :     int = 4				,		UpperCamelCase__      :     int = 32				,		UpperCamelCase__      :     int = 32				,		UpperCamelCase__      :     float = 0.1_82_15				,		)				->					List[str]:
								'''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__				,		)

								# 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__				,		norm_num_groups=UpperCamelCase__				,		act_fn=UpperCamelCase__				,		)

								UpperCAmelCase         =     nn.Convad(2 * latent_channels				,		2 * latent_channels				,		1      )
								UpperCAmelCase         =     nn.Convad(UpperCamelCase__				,		UpperCamelCase__				,		1      )

								UpperCAmelCase         =     False
								UpperCAmelCase         =     False

								# only relevant if vae tiling is enabled
								UpperCAmelCase         =     self.config.sample_size
								UpperCAmelCase         =     (
								    self.config.sample_size[0]
								    if isinstance(self.config.sample_size				,		(list, tuple)      )
								    else self.config.sample_size
								)
								UpperCAmelCase         =     int(sample_size / (2 ** (len(self.config.block_out_channels      ) - 1))      )
								UpperCAmelCase         =     0.25






		def SCREAMING_SNAKE_CASE_			(						self      :     Dict				,		UpperCamelCase__      :     Optional[int]				,		UpperCamelCase__      :     int=False      )				->					Optional[int]:
								'''simple docstring'''







								if isinstance(UpperCamelCase__				,		(Encoder, Decoder)      ):
														UpperCAmelCase         =     value






		def SCREAMING_SNAKE_CASE_			(						self      :     Optional[int]				,		UpperCamelCase__      :     bool = True      )				->					Tuple:
								'''simple docstring'''







								UpperCAmelCase         =     use_tiling






		def SCREAMING_SNAKE_CASE_			(						self      :     List[Any]      )				->					Tuple:
								'''simple docstring'''







								self.enable_tiling(UpperCamelCase__      )






		def SCREAMING_SNAKE_CASE_			(						self      :     Any      )				->					Tuple:
								'''simple docstring'''







								UpperCAmelCase         =     True






		def SCREAMING_SNAKE_CASE_			(						self      :     Dict      )				->					List[str]:
								'''simple docstring'''







								UpperCAmelCase         =     False






		@property
		# Copied from diffusers.models.unet_2d_condition.UNet2DConditionModel.attn_processors
		def SCREAMING_SNAKE_CASE_			(						self      :     str      )				->					Dict[str, AttentionProcessor]:
								'''simple docstring'''







								UpperCAmelCase         =     {}

								def fn_recursive_add_processors(UpperCamelCase__      :     str				,		UpperCamelCase__      :     torch.nn.Module				,		UpperCamelCase__      :     Dict[str, AttentionProcessor]      ):
														if hasattr(UpperCamelCase__				,		"set_processor"      ):
																				UpperCAmelCase         =     module.processor

														for sub_name, child in module.named_children():
																				fn_recursive_add_processors(F'{name}.{sub_name}'				,		UpperCamelCase__				,		UpperCamelCase__      )

														return processors

								for name, module in self.named_children():
														fn_recursive_add_processors(UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__      )

								return processors






		def SCREAMING_SNAKE_CASE_			(						self      :     Union[str, Any]				,		UpperCamelCase__      :     Union[AttentionProcessor, Dict[str, AttentionProcessor]]      )				->					List[Any]:
								'''simple docstring'''







								UpperCAmelCase         =     len(self.attn_processors.keys()      )

								if isinstance(UpperCamelCase__				,		UpperCamelCase__      ) and len(UpperCamelCase__      ) != count:
														raise ValueError(
														    F'A dict of processors was passed, but the number of processors {len(UpperCamelCase__      )} does not match the'
														    F' number of attention layers: {count}. Please make sure to pass {count} processor classes.'      )

								def fn_recursive_attn_processor(UpperCamelCase__      :     str				,		UpperCamelCase__      :     torch.nn.Module				,		UpperCamelCase__      :     List[Any]      ):
														if hasattr(UpperCamelCase__				,		"set_processor"      ):
																				if not isinstance(UpperCamelCase__				,		UpperCamelCase__      ):
																										module.set_processor(UpperCamelCase__      )
																				else:
																										module.set_processor(processor.pop(F'{name}.processor'      )      )

														for sub_name, child in module.named_children():
																				fn_recursive_attn_processor(F'{name}.{sub_name}'				,		UpperCamelCase__				,		UpperCamelCase__      )

								for name, module in self.named_children():
														fn_recursive_attn_processor(UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__      )






		def SCREAMING_SNAKE_CASE_			(						self      :     Dict      )				->					Dict:
								'''simple docstring'''







								self.set_attn_processor(AttnProcessor()      )






		@apply_forward_hook
		def SCREAMING_SNAKE_CASE_			(						self      :     Any				,		UpperCamelCase__      :     torch.FloatTensor				,		UpperCamelCase__      :     bool = True      )				->					AutoencoderKLOutput:
								'''simple docstring'''







								if self.use_tiling and (x.shape[-1] > self.tile_sample_min_size or x.shape[-2] > self.tile_sample_min_size):
														return self.tiled_encode(UpperCamelCase__				,		return_dict=UpperCamelCase__      )

								if self.use_slicing and x.shape[0] > 1:
														UpperCAmelCase         =     [self.encoder(UpperCamelCase__      ) for x_slice in x.split(1      )]
														UpperCAmelCase         =     torch.cat(UpperCamelCase__      )
								else:
														UpperCAmelCase         =     self.encoder(UpperCamelCase__      )

								UpperCAmelCase         =     self.quant_conv(UpperCamelCase__      )
								UpperCAmelCase         =     DiagonalGaussianDistribution(UpperCamelCase__      )

								if not return_dict:
														return (posterior,)

								return AutoencoderKLOutput(latent_dist=UpperCamelCase__      )






		def SCREAMING_SNAKE_CASE_			(						self      :     List[str]				,		UpperCamelCase__      :     torch.FloatTensor				,		UpperCamelCase__      :     bool = True      )				->					Union[DecoderOutput, torch.FloatTensor]:
								'''simple docstring'''







								if self.use_tiling and (z.shape[-1] > self.tile_latent_min_size or z.shape[-2] > self.tile_latent_min_size):
														return self.tiled_decode(UpperCamelCase__				,		return_dict=UpperCamelCase__      )

								UpperCAmelCase         =     self.post_quant_conv(UpperCamelCase__      )
								UpperCAmelCase         =     self.decoder(UpperCamelCase__      )

								if not return_dict:
														return (dec,)

								return DecoderOutput(sample=UpperCamelCase__      )






		@apply_forward_hook
		def SCREAMING_SNAKE_CASE_			(						self      :     Any				,		UpperCamelCase__      :     torch.FloatTensor				,		UpperCamelCase__      :     bool = True      )				->					Union[DecoderOutput, torch.FloatTensor]:
								'''simple docstring'''







								if self.use_slicing and z.shape[0] > 1:
														UpperCAmelCase         =     [self._decode(UpperCamelCase__      ).sample for z_slice in z.split(1      )]
														UpperCAmelCase         =     torch.cat(UpperCamelCase__      )
								else:
														UpperCAmelCase         =     self._decode(UpperCamelCase__      ).sample

								if not return_dict:
														return (decoded,)

								return DecoderOutput(sample=UpperCamelCase__      )






		def SCREAMING_SNAKE_CASE_			(						self      :     Dict				,		UpperCamelCase__      :     Any				,		UpperCamelCase__      :     Tuple				,		UpperCamelCase__      :     Tuple      )				->					List[Any]:
								'''simple docstring'''







								UpperCAmelCase         =     min(a.shape[2]				,		b.shape[2]				,		UpperCamelCase__      )
								for y in range(UpperCamelCase__      ):
														UpperCAmelCase         =     a[:, :, -blend_extent + y, :] * (1 - y / blend_extent) + b[:, :, y, :] * (y / blend_extent)
								return b






		def SCREAMING_SNAKE_CASE_			(						self      :     str				,		UpperCamelCase__      :     Optional[Any]				,		UpperCamelCase__      :     Union[str, Any]				,		UpperCamelCase__      :     int      )				->					List[str]:
								'''simple docstring'''







								UpperCAmelCase         =     min(a.shape[3]				,		b.shape[3]				,		UpperCamelCase__      )
								for x in range(UpperCamelCase__      ):
														UpperCAmelCase         =     a[:, :, :, -blend_extent + x] * (1 - x / blend_extent) + b[:, :, :, x] * (x / blend_extent)
								return b






		def SCREAMING_SNAKE_CASE_			(						self      :     str				,		UpperCamelCase__      :     torch.FloatTensor				,		UpperCamelCase__      :     bool = True      )				->					AutoencoderKLOutput:
								'''simple docstring'''







								UpperCAmelCase         =     int(self.tile_sample_min_size * (1 - self.tile_overlap_factor)      )
								UpperCAmelCase         =     int(self.tile_latent_min_size * self.tile_overlap_factor      )
								UpperCAmelCase         =     self.tile_latent_min_size - blend_extent

								# Split the image into 512x512 tiles and encode them separately.
								UpperCAmelCase         =     []
								for i in range(0				,		x.shape[2]				,		UpperCamelCase__      ):
														UpperCAmelCase         =     []
														for j in range(0				,		x.shape[3]				,		UpperCamelCase__      ):
																				UpperCAmelCase         =     x[:, :, i : i + self.tile_sample_min_size, j : j + self.tile_sample_min_size]
																				UpperCAmelCase         =     self.encoder(UpperCamelCase__      )
																				UpperCAmelCase         =     self.quant_conv(UpperCamelCase__      )
																				row.append(UpperCamelCase__      )
														rows.append(UpperCamelCase__      )
								UpperCAmelCase         =     []
								for i, row in enumerate(UpperCamelCase__      ):
														UpperCAmelCase         =     []
														for j, tile in enumerate(UpperCamelCase__      ):
																				# blend the above tile and the left tile
																				# to the current tile and add the current tile to the result row
																				if i > 0:
																										UpperCAmelCase         =     self.blend_v(rows[i - 1][j]				,		UpperCamelCase__				,		UpperCamelCase__      )
																				if j > 0:
																										UpperCAmelCase         =     self.blend_h(row[j - 1]				,		UpperCamelCase__				,		UpperCamelCase__      )
																				result_row.append(tile[:, :, :row_limit, :row_limit]      )
														result_rows.append(torch.cat(UpperCamelCase__				,		dim=3      )      )

								UpperCAmelCase         =     torch.cat(UpperCamelCase__				,		dim=2      )
								UpperCAmelCase         =     DiagonalGaussianDistribution(UpperCamelCase__      )

								if not return_dict:
														return (posterior,)

								return AutoencoderKLOutput(latent_dist=UpperCamelCase__      )






		def SCREAMING_SNAKE_CASE_			(						self      :     List[Any]				,		UpperCamelCase__      :     torch.FloatTensor				,		UpperCamelCase__      :     bool = True      )				->					Union[DecoderOutput, torch.FloatTensor]:
								'''simple docstring'''







								UpperCAmelCase         =     int(self.tile_latent_min_size * (1 - self.tile_overlap_factor)      )
								UpperCAmelCase         =     int(self.tile_sample_min_size * self.tile_overlap_factor      )
								UpperCAmelCase         =     self.tile_sample_min_size - blend_extent

								# Split z into overlapping 64x64 tiles and decode them separately.
								# The tiles have an overlap to avoid seams between tiles.
								UpperCAmelCase         =     []
								for i in range(0				,		z.shape[2]				,		UpperCamelCase__      ):
														UpperCAmelCase         =     []
														for j in range(0				,		z.shape[3]				,		UpperCamelCase__      ):
																				UpperCAmelCase         =     z[:, :, i : i + self.tile_latent_min_size, j : j + self.tile_latent_min_size]
																				UpperCAmelCase         =     self.post_quant_conv(UpperCamelCase__      )
																				UpperCAmelCase         =     self.decoder(UpperCamelCase__      )
																				row.append(UpperCamelCase__      )
														rows.append(UpperCamelCase__      )
								UpperCAmelCase         =     []
								for i, row in enumerate(UpperCamelCase__      ):
														UpperCAmelCase         =     []
														for j, tile in enumerate(UpperCamelCase__      ):
																				# blend the above tile and the left tile
																				# to the current tile and add the current tile to the result row
																				if i > 0:
																										UpperCAmelCase         =     self.blend_v(rows[i - 1][j]				,		UpperCamelCase__				,		UpperCamelCase__      )
																				if j > 0:
																										UpperCAmelCase         =     self.blend_h(row[j - 1]				,		UpperCamelCase__				,		UpperCamelCase__      )
																				result_row.append(tile[:, :, :row_limit, :row_limit]      )
														result_rows.append(torch.cat(UpperCamelCase__				,		dim=3      )      )

								UpperCAmelCase         =     torch.cat(UpperCamelCase__				,		dim=2      )
								if not return_dict:
														return (dec,)

								return DecoderOutput(sample=UpperCamelCase__      )







		def SCREAMING_SNAKE_CASE_			(						self      :     List[str]				,		UpperCamelCase__      :     torch.FloatTensor				,		UpperCamelCase__      :     bool = False				,		UpperCamelCase__      :     bool = True				,		UpperCamelCase__      :     Optional[torch.Generator] = None				,		)				->					Union[DecoderOutput, torch.FloatTensor]:
								'''simple docstring'''







								UpperCAmelCase         =     sample
								UpperCAmelCase         =     self.encode(UpperCamelCase__      ).latent_dist
								if sample_posterior:
														UpperCAmelCase         =     posterior.sample(generator=UpperCamelCase__      )
								else:
														UpperCAmelCase         =     posterior.mode()
								UpperCAmelCase         =     self.decode(UpperCamelCase__      ).sample

								if not return_dict:
														return (dec,)

								return DecoderOutput(sample=UpperCamelCase__      )



