"""simple docstring"""







from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    get_resize_output_image_size,
    normalize,
    pad,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    get_image_size,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging
from ...utils.import_utils import is_vision_available


_SCREAMING_SNAKE_CASE	:		Dict   =   logging.get_logger(__name__)


if is_vision_available():
     import PIL






class      _SCREAMING_SNAKE_CASE							(			UpperCAmelCase				):



   '''simple docstring'''



   __UpperCAmelCase	:							int    =    ["pixel_values"]







   def __init__(	self ,				_SCREAMING_SNAKE_CASE = True ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = PILImageResampling.BILINEAR ,				_SCREAMING_SNAKE_CASE = True ,				_SCREAMING_SNAKE_CASE = False ,				_SCREAMING_SNAKE_CASE = True ,				_SCREAMING_SNAKE_CASE = True ,				_SCREAMING_SNAKE_CASE = 1 / 255 ,				_SCREAMING_SNAKE_CASE = True ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				**_SCREAMING_SNAKE_CASE ,				):


      '''simple docstring'''

      super().__init__(**_SCREAMING_SNAKE_CASE	)

      __lowerCamelCase    		=					size if size is not None else {'height': 2560, 'width': 1920}
      if isinstance(_SCREAMING_SNAKE_CASE ,				(tuple, list)	):
         # The previous feature extractor size parameter was in (width, height) format
         __lowerCamelCase    		=					size[::-1]
      __lowerCamelCase    		=					get_size_dict(_SCREAMING_SNAKE_CASE	)

      __lowerCamelCase    		=					do_resize
      __lowerCamelCase    		=					size
      __lowerCamelCase    		=					resample
      __lowerCamelCase    		=					do_thumbnail
      __lowerCamelCase    		=					do_align_long_axis
      __lowerCamelCase    		=					do_pad
      __lowerCamelCase    		=					do_rescale
      __lowerCamelCase    		=					rescale_factor
      __lowerCamelCase    		=					do_normalize
      __lowerCamelCase    		=					image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
      __lowerCamelCase    		=					image_std if image_std is not None else IMAGENET_STANDARD_STD







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = None	):


      '''simple docstring'''

      __lowerCamelCase		,__lowerCamelCase    		=					get_image_size(_SCREAMING_SNAKE_CASE	)
      __lowerCamelCase		,__lowerCamelCase    		=					size['height'], size['width']

      if (output_width < output_height and input_width > input_height) or (
          output_width > output_height and input_width < input_height
      ):
         __lowerCamelCase    		=					np.rotaa(_SCREAMING_SNAKE_CASE ,				3	)

      if data_format is not None:
         __lowerCamelCase    		=					to_channel_dimension_format(_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE	)

      return image







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = False ,				_SCREAMING_SNAKE_CASE = None ,				):


      '''simple docstring'''

      __lowerCamelCase		,__lowerCamelCase    		=					size['height'], size['width']
      __lowerCamelCase		,__lowerCamelCase    		=					get_image_size(_SCREAMING_SNAKE_CASE	)

      __lowerCamelCase    		=					output_width - input_width
      __lowerCamelCase    		=					output_height - input_height

      if random_padding:
         __lowerCamelCase    		=					np.random.randint(low=0 ,				high=delta_height + 1	)
         __lowerCamelCase    		=					np.random.randint(low=0 ,				high=delta_width + 1	)
      else:
         __lowerCamelCase    		=					delta_height // 2
         __lowerCamelCase    		=					delta_width // 2

      __lowerCamelCase    		=					delta_height - pad_top
      __lowerCamelCase    		=					delta_width - pad_left

      __lowerCamelCase    		=					((pad_top, pad_bottom), (pad_left, pad_right))
      return pad(_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE ,				data_format=_SCREAMING_SNAKE_CASE	)







   def    _A				(	self ,				*_SCREAMING_SNAKE_CASE ,				**_SCREAMING_SNAKE_CASE	):


      '''simple docstring'''

      logger.info('pad is deprecated and will be removed in version 4.27. Please use pad_image instead.'	)
      return self.pad_image(*_SCREAMING_SNAKE_CASE ,				**_SCREAMING_SNAKE_CASE	)







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = PILImageResampling.BICUBIC ,				_SCREAMING_SNAKE_CASE = None ,				**_SCREAMING_SNAKE_CASE ,				):


      '''simple docstring'''

      __lowerCamelCase		,__lowerCamelCase    		=					get_image_size(_SCREAMING_SNAKE_CASE	)
      __lowerCamelCase		,__lowerCamelCase    		=					size['height'], size['width']

      # We always resize to the smallest of either the input or output size.
      __lowerCamelCase    		=					min(_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE	)
      __lowerCamelCase    		=					min(_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE	)

      if height == input_height and width == input_width:
         return image

      if input_height > input_width:
         __lowerCamelCase    		=					int(input_width * height / input_height	)
      elif input_width > input_height:
         __lowerCamelCase    		=					int(input_height * width / input_width	)

      return resize(
          _SCREAMING_SNAKE_CASE ,				size=(height, width) ,				resample=_SCREAMING_SNAKE_CASE ,				reducing_gap=2.0 ,				data_format=_SCREAMING_SNAKE_CASE ,				**_SCREAMING_SNAKE_CASE	)







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = PILImageResampling.BICUBIC ,				_SCREAMING_SNAKE_CASE = None ,				**_SCREAMING_SNAKE_CASE ,				):


      '''simple docstring'''

      __lowerCamelCase    		=					get_size_dict(_SCREAMING_SNAKE_CASE	)
      __lowerCamelCase    		=					min(size['height'] ,				size['width']	)
      __lowerCamelCase    		=					get_resize_output_image_size(_SCREAMING_SNAKE_CASE ,				size=_SCREAMING_SNAKE_CASE ,				default_to_square=_SCREAMING_SNAKE_CASE	)
      __lowerCamelCase    		=					resize(_SCREAMING_SNAKE_CASE ,				size=_SCREAMING_SNAKE_CASE ,				resample=_SCREAMING_SNAKE_CASE ,				data_format=_SCREAMING_SNAKE_CASE ,				**_SCREAMING_SNAKE_CASE	)
      return resized_image







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = None ,				**_SCREAMING_SNAKE_CASE ,				):


      '''simple docstring'''

      return rescale(_SCREAMING_SNAKE_CASE ,				scale=_SCREAMING_SNAKE_CASE ,				data_format=_SCREAMING_SNAKE_CASE ,				**_SCREAMING_SNAKE_CASE	)







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = None ,				**_SCREAMING_SNAKE_CASE ,				):


      '''simple docstring'''

      return normalize(_SCREAMING_SNAKE_CASE ,				mean=_SCREAMING_SNAKE_CASE ,				std=_SCREAMING_SNAKE_CASE ,				data_format=_SCREAMING_SNAKE_CASE ,				**_SCREAMING_SNAKE_CASE	)







   def    _A				(	self ,				_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = False ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = None ,				_SCREAMING_SNAKE_CASE = ChannelDimension.FIRST ,				**_SCREAMING_SNAKE_CASE ,				):


      '''simple docstring'''

      __lowerCamelCase    		=					do_resize if do_resize is not None else self.do_resize
      __lowerCamelCase    		=					size if size is not None else self.size
      if isinstance(_SCREAMING_SNAKE_CASE ,				(tuple, list)	):
         # Previous feature extractor had size in (width, height) format
         __lowerCamelCase    		=					size[::-1]
      __lowerCamelCase    		=					get_size_dict(_SCREAMING_SNAKE_CASE	)
      __lowerCamelCase    		=					resample if resample is not None else self.resample
      __lowerCamelCase    		=					do_thumbnail if do_thumbnail is not None else self.do_thumbnail
      __lowerCamelCase    		=					do_align_long_axis if do_align_long_axis is not None else self.do_align_long_axis
      __lowerCamelCase    		=					do_pad if do_pad is not None else self.do_pad
      __lowerCamelCase    		=					do_rescale if do_rescale is not None else self.do_rescale
      __lowerCamelCase    		=					rescale_factor if rescale_factor is not None else self.rescale_factor
      __lowerCamelCase    		=					do_normalize if do_normalize is not None else self.do_normalize
      __lowerCamelCase    		=					image_mean if image_mean is not None else self.image_mean
      __lowerCamelCase    		=					image_std if image_std is not None else self.image_std

      __lowerCamelCase    		=					make_list_of_images(_SCREAMING_SNAKE_CASE	)

      if not valid_images(_SCREAMING_SNAKE_CASE	):
         raise ValueError(
             'Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '
             'torch.Tensor, tf.Tensor or jax.ndarray.'	)

      if do_resize and size is None:
         raise ValueError('Size must be specified if do_resize is True.'	)

      if do_rescale and rescale_factor is None:
         raise ValueError('Rescale factor must be specified if do_rescale is True.'	)

      if do_pad and size is None:
         raise ValueError('Size must be specified if do_pad is True.'	)

      if do_normalize and (image_mean is None or image_std is None):
         raise ValueError('Image mean and std must be specified if do_normalize is True.'	)

      # All transformations expect numpy arrays.
      __lowerCamelCase    		=					[to_numpy_array(_SCREAMING_SNAKE_CASE	) for image in images]

      if do_align_long_axis:
         __lowerCamelCase    		=					[self.align_long_axis(_SCREAMING_SNAKE_CASE ,				size=_SCREAMING_SNAKE_CASE	) for image in images]

      if do_resize:
         __lowerCamelCase    		=					[self.resize(image=_SCREAMING_SNAKE_CASE ,				size=_SCREAMING_SNAKE_CASE ,				resample=_SCREAMING_SNAKE_CASE	) for image in images]

      if do_thumbnail:
         __lowerCamelCase    		=					[self.thumbnail(image=_SCREAMING_SNAKE_CASE ,				size=_SCREAMING_SNAKE_CASE	) for image in images]

      if do_pad:
         __lowerCamelCase    		=					[self.pad_image(image=_SCREAMING_SNAKE_CASE ,				size=_SCREAMING_SNAKE_CASE ,				random_padding=_SCREAMING_SNAKE_CASE	) for image in images]

      if do_rescale:
         __lowerCamelCase    		=					[self.rescale(image=_SCREAMING_SNAKE_CASE ,				scale=_SCREAMING_SNAKE_CASE	) for image in images]

      if do_normalize:
         __lowerCamelCase    		=					[self.normalize(image=_SCREAMING_SNAKE_CASE ,				mean=_SCREAMING_SNAKE_CASE ,				std=_SCREAMING_SNAKE_CASE	) for image in images]

      __lowerCamelCase    		=					[to_channel_dimension_format(_SCREAMING_SNAKE_CASE ,				_SCREAMING_SNAKE_CASE	) for image in images]

      __lowerCamelCase    		=					{'pixel_values': images}
      return BatchFeature(data=_SCREAMING_SNAKE_CASE ,				tensor_type=_SCREAMING_SNAKE_CASE	)








"""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
from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps
from .modeling_utils import ModelMixin
from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block







@dataclass
class 	_lowercase    (							lowerCAmelCase_					):


     '''simple docstring'''





     _A		    =				42







class 	_lowercase    (							lowerCAmelCase_						, lowerCAmelCase_					):


     '''simple docstring'''





     @register_to_config
     def __init__(   self			,      __UpperCamelCase = None			,      __UpperCamelCase = 3			,      __UpperCamelCase = 3			,      __UpperCamelCase = False			,      __UpperCamelCase = "positional"			,      __UpperCamelCase = 0			,      __UpperCamelCase = True			,      __UpperCamelCase = ("DownBlock2D", "AttnDownBlock2D", "AttnDownBlock2D", "AttnDownBlock2D")			,      __UpperCamelCase = ("AttnUpBlock2D", "AttnUpBlock2D", "AttnUpBlock2D", "UpBlock2D")			,      __UpperCamelCase = (2_24, 4_48, 6_72, 8_96)			,      __UpperCamelCase = 2			,      __UpperCamelCase = 1			,      __UpperCamelCase = 1			,      __UpperCamelCase = "conv"			,      __UpperCamelCase = "conv"			,      __UpperCamelCase = "silu"			,      __UpperCamelCase = 8			,      __UpperCamelCase = 32			,      __UpperCamelCase = 1E-5			,      __UpperCamelCase = "default"			,      __UpperCamelCase = True			,      __UpperCamelCase = None			,      __UpperCamelCase = None			,      )->       Any:
          super().__init__()

          UpperCAmelCase__				:			Optional[int]							=    sample_size
          UpperCAmelCase__				:			Any							=    block_out_channels[0] * 4

          # Check inputs
          if len(__UpperCamelCase	) != len(__UpperCamelCase	):
               raise ValueError(
                   F"Must provide the same number of `down_block_types` as `up_block_types`. `down_block_types`: {down_block_types}. `up_block_types`: {up_block_types}."	)

          if len(__UpperCamelCase	) != len(__UpperCamelCase	):
               raise ValueError(
                   F"Must provide the same number of `block_out_channels` as `down_block_types`. `block_out_channels`: {block_out_channels}. `down_block_types`: {down_block_types}."	)

          # input
          UpperCAmelCase__				:			List[Any]							=    nn.Convad(__UpperCamelCase			,      block_out_channels[0]			,      kernel_size=3			,      padding=(1, 1)	)

          # time
          if time_embedding_type == "fourier":
               UpperCAmelCase__				:			int							=    GaussianFourierProjection(embedding_size=block_out_channels[0]			,      scale=16	)
               UpperCAmelCase__				:			Dict							=    2 * block_out_channels[0]
          elif time_embedding_type == "positional":
               UpperCAmelCase__				:			List[str]							=    Timesteps(block_out_channels[0]			,      __UpperCamelCase			,      __UpperCamelCase	)
               UpperCAmelCase__				:			Any							=    block_out_channels[0]

          UpperCAmelCase__				:			List[str]							=    TimestepEmbedding(__UpperCamelCase			,      __UpperCamelCase	)

          # class embedding
          if class_embed_type is None and num_class_embeds is not None:
               UpperCAmelCase__				:			Optional[Any]							=    nn.Embedding(__UpperCamelCase			,      __UpperCamelCase	)
          elif class_embed_type == "timestep":
               UpperCAmelCase__				:			str							=    TimestepEmbedding(__UpperCamelCase			,      __UpperCamelCase	)
          elif class_embed_type == "identity":
               UpperCAmelCase__				:			Union[str, Any]							=    nn.Identity(__UpperCamelCase			,      __UpperCamelCase	)
          else:
               UpperCAmelCase__				:			Optional[int]							=    None

          UpperCAmelCase__				:			str							=    nn.ModuleList([]	)
          UpperCAmelCase__				:			Any							=    None
          UpperCAmelCase__				:			Tuple							=    nn.ModuleList([]	)

          # down
          UpperCAmelCase__				:			Any							=    block_out_channels[0]
          for i, down_block_type in enumerate(__UpperCamelCase	):
               UpperCAmelCase__				:			List[Any]							=    output_channel
               UpperCAmelCase__				:			Optional[int]							=    block_out_channels[i]
               UpperCAmelCase__				:			Any							=    i == len(__UpperCamelCase	) - 1

               UpperCAmelCase__				:			List[Any]							=    get_down_block(
                   __UpperCamelCase			,      num_layers=__UpperCamelCase			,      in_channels=__UpperCamelCase			,      out_channels=__UpperCamelCase			,      temb_channels=__UpperCamelCase			,      add_downsample=not is_final_block			,      resnet_eps=__UpperCamelCase			,      resnet_act_fn=__UpperCamelCase			,      resnet_groups=__UpperCamelCase			,      attention_head_dim=attention_head_dim if attention_head_dim is not None else output_channel			,      downsample_padding=__UpperCamelCase			,      resnet_time_scale_shift=__UpperCamelCase			,      downsample_type=__UpperCamelCase			,      )
               self.down_blocks.append(__UpperCamelCase	)

          # mid
          UpperCAmelCase__				:			List[str]							=    UNetMidBlockaD(
              in_channels=block_out_channels[-1]			,      temb_channels=__UpperCamelCase			,      resnet_eps=__UpperCamelCase			,      resnet_act_fn=__UpperCamelCase			,      output_scale_factor=__UpperCamelCase			,      resnet_time_scale_shift=__UpperCamelCase			,      attention_head_dim=attention_head_dim if attention_head_dim is not None else block_out_channels[-1]			,      resnet_groups=__UpperCamelCase			,      add_attention=__UpperCamelCase			,      )

          # up
          UpperCAmelCase__				:			Tuple							=    list(reversed(__UpperCamelCase	)	)
          UpperCAmelCase__				:			Optional[Any]							=    reversed_block_out_channels[0]
          for i, up_block_type in enumerate(__UpperCamelCase	):
               UpperCAmelCase__				:			int							=    output_channel
               UpperCAmelCase__				:			List[Any]							=    reversed_block_out_channels[i]
               UpperCAmelCase__				:			Dict							=    reversed_block_out_channels[min(i + 1			,      len(__UpperCamelCase	) - 1	)]

               UpperCAmelCase__				:			int							=    i == len(__UpperCamelCase	) - 1

               UpperCAmelCase__				:			Dict							=    get_up_block(
                   __UpperCamelCase			,      num_layers=layers_per_block + 1			,      in_channels=__UpperCamelCase			,      out_channels=__UpperCamelCase			,      prev_output_channel=__UpperCamelCase			,      temb_channels=__UpperCamelCase			,      add_upsample=not is_final_block			,      resnet_eps=__UpperCamelCase			,      resnet_act_fn=__UpperCamelCase			,      resnet_groups=__UpperCamelCase			,      attention_head_dim=attention_head_dim if attention_head_dim is not None else output_channel			,      resnet_time_scale_shift=__UpperCamelCase			,      upsample_type=__UpperCamelCase			,      )
               self.up_blocks.append(__UpperCamelCase	)
               UpperCAmelCase__				:			Dict							=    output_channel

          # out
          UpperCAmelCase__				:			str							=    norm_num_groups if norm_num_groups is not None else min(block_out_channels[0] // 4			,      32	)
          UpperCAmelCase__				:			Tuple							=    nn.GroupNorm(num_channels=block_out_channels[0]			,      num_groups=__UpperCamelCase			,      eps=__UpperCamelCase	)
          UpperCAmelCase__				:			Any							=    nn.SiLU()
          UpperCAmelCase__				:			Optional[int]							=    nn.Convad(block_out_channels[0]			,      __UpperCamelCase			,      kernel_size=3			,      padding=1	)



     def 			lowerCAmelCase__							(   self			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase = None			,      __UpperCamelCase = True			,      )->       Union[UNetaDOutput, Tuple]:
          # 0. center input if necessary
          if self.config.center_input_sample:
               UpperCAmelCase__				:			Any							=    2 * sample - 1.0

          # 1. time
          UpperCAmelCase__				:			Tuple							=    timestep
          if not torch.is_tensor(__UpperCamelCase	):
               UpperCAmelCase__				:			Optional[int]							=    torch.tensor([timesteps]			,      dtype=torch.long			,      device=sample.device	)
          elif torch.is_tensor(__UpperCamelCase	) and len(timesteps.shape	) == 0:
               UpperCAmelCase__				:			List[Any]							=    timesteps[None].to(sample.device	)

          # broadcast to batch dimension in a way that's compatible with ONNX/Core ML
          UpperCAmelCase__				:			Dict							=    timesteps * torch.ones(sample.shape[0]			,      dtype=timesteps.dtype			,      device=timesteps.device	)

          UpperCAmelCase__				:			List[str]							=    self.time_proj(__UpperCamelCase	)

          # timesteps does not contain any weights and will always return f32 tensors
          # but time_embedding might actually be running in fp16. so we need to cast here.
          # there might be better ways to encapsulate this.
          UpperCAmelCase__				:			Dict							=    t_emb.to(dtype=self.dtype	)
          UpperCAmelCase__				:			Optional[int]							=    self.time_embedding(__UpperCamelCase	)

          if self.class_embedding is not None:
               if class_labels is None:
                    raise ValueError("class_labels should be provided when doing class conditioning"	)

               if self.config.class_embed_type == "timestep":
                    UpperCAmelCase__				:			List[Any]							=    self.time_proj(__UpperCamelCase	)

               UpperCAmelCase__				:			List[str]							=    self.class_embedding(__UpperCamelCase	).to(dtype=self.dtype	)
               UpperCAmelCase__				:			Optional[int]							=    emb + class_emb

          # 2. pre-process
          UpperCAmelCase__				:			List[str]							=    sample
          UpperCAmelCase__				:			str							=    self.conv_in(__UpperCamelCase	)

          # 3. down
          UpperCAmelCase__				:			List[str]							=    (sample,)
          for downsample_block in self.down_blocks:
               if hasattr(__UpperCamelCase			,      "skip_conv"	):
                    UpperCAmelCase__				,						UpperCAmelCase__				,						UpperCAmelCase__				:			Optional[Any]							=    downsample_block(
                        hidden_states=__UpperCamelCase			,      temb=__UpperCamelCase			,      skip_sample=__UpperCamelCase	)
               else:
                    UpperCAmelCase__				,						UpperCAmelCase__				:			Optional[Any]							=    downsample_block(hidden_states=__UpperCamelCase			,      temb=__UpperCamelCase	)

               down_block_res_samples += res_samples

          # 4. mid
          UpperCAmelCase__				:			Union[str, Any]							=    self.mid_block(__UpperCamelCase			,      __UpperCamelCase	)

          # 5. up
          UpperCAmelCase__				:			Dict							=    None
          for upsample_block in self.up_blocks:
               UpperCAmelCase__				:			Union[str, Any]							=    down_block_res_samples[-len(upsample_block.resnets	) :]
               UpperCAmelCase__				:			Optional[Any]							=    down_block_res_samples[: -len(upsample_block.resnets	)]

               if hasattr(__UpperCamelCase			,      "skip_conv"	):
                    UpperCAmelCase__				,						UpperCAmelCase__				:			str							=    upsample_block(__UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase	)
               else:
                    UpperCAmelCase__				:			Tuple							=    upsample_block(__UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase	)

        # 6. post-process
          UpperCAmelCase__				:			List[Any]							=    self.conv_norm_out(__UpperCamelCase	)
          UpperCAmelCase__				:			Any							=    self.conv_act(__UpperCamelCase	)
          UpperCAmelCase__				:			Optional[Any]							=    self.conv_out(__UpperCamelCase	)

          if skip_sample is not None:
               sample += skip_sample

          if self.config.time_embedding_type == "fourier":
               UpperCAmelCase__				:			str							=    timesteps.reshape((sample.shape[0], *([1] * len(sample.shape[1:]	)))	)
               UpperCAmelCase__				:			int							=    sample / timesteps

          if not return_dict:
               return (sample,)

          return UNetaDOutput(sample=__UpperCamelCase	)



