


'''simple docstring'''






import argparse
import os

import torch

from diffusers import (
    CMStochasticIterativeScheduler,
    ConsistencyModelPipeline,
    UNetaDModel,
)


__A :  Tuple    							=				{
    "sample_size": 32,
    "in_channels": 3,
    "out_channels": 3,
    "layers_per_block": 2,
    "num_class_embeds": 1000,
    "block_out_channels": [32, 64],
    "attention_head_dim": 8,
    "down_block_types": [
        "ResnetDownsampleBlock2D",
        "AttnDownBlock2D",
    ],
    "up_block_types": [
        "AttnUpBlock2D",
        "ResnetUpsampleBlock2D",
    ],
    "resnet_time_scale_shift": "scale_shift",
    "upsample_type": "resnet",
    "downsample_type": "resnet",
}

__A :  Any    							=				{
    "sample_size": 64,
    "in_channels": 3,
    "out_channels": 3,
    "layers_per_block": 3,
    "num_class_embeds": 1000,
    "block_out_channels": [192, 192 * 2, 192 * 3, 192 * 4],
    "attention_head_dim": 64,
    "down_block_types": [
        "ResnetDownsampleBlock2D",
        "AttnDownBlock2D",
        "AttnDownBlock2D",
        "AttnDownBlock2D",
    ],
    "up_block_types": [
        "AttnUpBlock2D",
        "AttnUpBlock2D",
        "AttnUpBlock2D",
        "ResnetUpsampleBlock2D",
    ],
    "resnet_time_scale_shift": "scale_shift",
    "upsample_type": "resnet",
    "downsample_type": "resnet",
}

__A :  str    							=				{
    "sample_size": 256,
    "in_channels": 3,
    "out_channels": 3,
    "layers_per_block": 2,
    "num_class_embeds": None,
    "block_out_channels": [256, 256, 256 * 2, 256 * 2, 256 * 4, 256 * 4],
    "attention_head_dim": 64,
    "down_block_types": [
        "ResnetDownsampleBlock2D",
        "ResnetDownsampleBlock2D",
        "ResnetDownsampleBlock2D",
        "AttnDownBlock2D",
        "AttnDownBlock2D",
        "AttnDownBlock2D",
    ],
    "up_block_types": [
        "AttnUpBlock2D",
        "AttnUpBlock2D",
        "AttnUpBlock2D",
        "ResnetUpsampleBlock2D",
        "ResnetUpsampleBlock2D",
        "ResnetUpsampleBlock2D",
    ],
    "resnet_time_scale_shift": "default",
    "upsample_type": "resnet",
    "downsample_type": "resnet",
}

__A :  Optional[int]    							=				{
    "num_train_timesteps": 40,
    "sigma_min": 0.0_0_2,
    "sigma_max": 8_0.0,
}

__A :  Union[str, Any]    							=				{
    "num_train_timesteps": 201,
    "sigma_min": 0.0_0_2,
    "sigma_max": 8_0.0,
}

__A :  Optional[Any]    							=				{
    "num_train_timesteps": 151,
    "sigma_min": 0.0_0_2,
    "sigma_max": 8_0.0,
}







def     UpperCamelCase_      (   A__ :       str ):
  '''simple docstring'''





  if isinstance(A__							,   A__ ):
    return v
  if v.lower() in ("yes", "true", "t", "y", "1"):
    return True
  elif v.lower() in ("no", "false", "f", "n", "0"):
    return False
  else:
    raise argparse.ArgumentTypeError("""boolean value expected""" )







def     UpperCamelCase_      (   A__ :       Tuple							,   A__ :       Tuple							,   A__ :       str							,   A__ :       Tuple							,   A__ :       Any=False ):
  '''simple docstring'''





  lowerCAmelCase_      :				Dict      =       checkpoint[f'{old_prefix}.in_layers.0.weight']
  lowerCAmelCase_      :				Any      =       checkpoint[f'{old_prefix}.in_layers.0.bias']
  lowerCAmelCase_      :				Tuple      =       checkpoint[f'{old_prefix}.in_layers.2.weight']
  lowerCAmelCase_      :				Optional[int]      =       checkpoint[f'{old_prefix}.in_layers.2.bias']
  lowerCAmelCase_      :				Optional[int]      =       checkpoint[f'{old_prefix}.emb_layers.1.weight']
  lowerCAmelCase_      :				List[Any]      =       checkpoint[f'{old_prefix}.emb_layers.1.bias']
  lowerCAmelCase_      :				Tuple      =       checkpoint[f'{old_prefix}.out_layers.0.weight']
  lowerCAmelCase_      :				Optional[Any]      =       checkpoint[f'{old_prefix}.out_layers.0.bias']
  lowerCAmelCase_      :				Union[str, Any]      =       checkpoint[f'{old_prefix}.out_layers.3.weight']
  lowerCAmelCase_      :				Optional[Any]      =       checkpoint[f'{old_prefix}.out_layers.3.bias']

  if has_skip:
    lowerCAmelCase_      :				Any      =       checkpoint[f'{old_prefix}.skip_connection.weight']
    lowerCAmelCase_      :				Union[str, Any]      =       checkpoint[f'{old_prefix}.skip_connection.bias']

  return new_checkpoint







def     UpperCamelCase_      (   A__ :       Dict							,   A__ :       Any							,   A__ :       int							,   A__ :       Optional[Any]							,   A__ :       Union[str, Any]=None ):
  '''simple docstring'''





  lowerCAmelCase_,							lowerCAmelCase_,							lowerCAmelCase_      :				str      =       checkpoint[f'{old_prefix}.qkv.weight'].chunk(3							,   dim=0 )
  lowerCAmelCase_,							lowerCAmelCase_,							lowerCAmelCase_      :				List[str]      =       checkpoint[f'{old_prefix}.qkv.bias'].chunk(3							,   dim=0 )

  lowerCAmelCase_      :				Any      =       checkpoint[f'{old_prefix}.norm.weight']
  lowerCAmelCase_      :				Union[str, Any]      =       checkpoint[f'{old_prefix}.norm.bias']

  lowerCAmelCase_      :				Any      =       weight_q.squeeze(-1 ).squeeze(-1 )
  lowerCAmelCase_      :				Tuple      =       bias_q.squeeze(-1 ).squeeze(-1 )
  lowerCAmelCase_      :				Any      =       weight_k.squeeze(-1 ).squeeze(-1 )
  lowerCAmelCase_      :				Optional[int]      =       bias_k.squeeze(-1 ).squeeze(-1 )
  lowerCAmelCase_      :				Dict      =       weight_v.squeeze(-1 ).squeeze(-1 )
  lowerCAmelCase_      :				int      =       bias_v.squeeze(-1 ).squeeze(-1 )

  lowerCAmelCase_      :				List[Any]      =       (
      checkpoint[f'{old_prefix}.proj_out.weight'].squeeze(-1 ).squeeze(-1 )
  )
  lowerCAmelCase_      :				Dict      =       checkpoint[f'{old_prefix}.proj_out.bias'].squeeze(-1 ).squeeze(-1 )

  return new_checkpoint







def     UpperCamelCase_      (   A__ :       str							,   A__ :       List[Any] ):
  '''simple docstring'''





  lowerCAmelCase_      :				Optional[Any]      =       torch.load(A__							,   map_location="""cpu""" )
  lowerCAmelCase_      :				Tuple      =       {}

  lowerCAmelCase_      :				Optional[Any]      =       checkpoint["""time_embed.0.weight"""]
  lowerCAmelCase_      :				List[str]      =       checkpoint["""time_embed.0.bias"""]
  lowerCAmelCase_      :				Union[str, Any]      =       checkpoint["""time_embed.2.weight"""]
  lowerCAmelCase_      :				Dict      =       checkpoint["""time_embed.2.bias"""]

  if unet_config["num_class_embeds"] is not None:
    lowerCAmelCase_      :				List[Any]      =       checkpoint["""label_emb.weight"""]

  lowerCAmelCase_      :				List[str]      =       checkpoint["""input_blocks.0.0.weight"""]
  lowerCAmelCase_      :				Any      =       checkpoint["""input_blocks.0.0.bias"""]

  lowerCAmelCase_      :				int      =       unet_config["""down_block_types"""]
  lowerCAmelCase_      :				List[Any]      =       unet_config["""layers_per_block"""]
  lowerCAmelCase_      :				int      =       unet_config["""attention_head_dim"""]
  lowerCAmelCase_      :				Dict      =       unet_config["""block_out_channels"""]
  lowerCAmelCase_      :				Optional[Any]      =       1
  lowerCAmelCase_      :				Tuple      =       channels_list[0]

  for i, layer_type in enumerate(A__ ):
    lowerCAmelCase_      :				Optional[int]      =       channels_list[i]
    lowerCAmelCase_      :				Union[str, Any]      =       current_channels != prev_channels
    if layer_type == "ResnetDownsampleBlock2D":
      for j in range(A__ ):
        lowerCAmelCase_      :				List[Any]      =       f'down_blocks.{i}.resnets.{j}'
        lowerCAmelCase_      :				Union[str, Any]      =       f'input_blocks.{current_layer}.0'
        lowerCAmelCase_      :				Union[str, Any]      =       True if j == 0 and downsample_block_has_skip else False
        lowerCAmelCase_      :				Dict      =       convert_resnet(A__							,   A__							,   A__							,   A__							,   has_skip=A__ )
        current_layer += 1

    elif layer_type == "AttnDownBlock2D":
      for j in range(A__ ):
        lowerCAmelCase_      :				Dict      =       f'down_blocks.{i}.resnets.{j}'
        lowerCAmelCase_      :				Tuple      =       f'input_blocks.{current_layer}.0'
        lowerCAmelCase_      :				str      =       True if j == 0 and downsample_block_has_skip else False
        lowerCAmelCase_      :				List[str]      =       convert_resnet(A__							,   A__							,   A__							,   A__							,   has_skip=A__ )
        lowerCAmelCase_      :				Union[str, Any]      =       f'down_blocks.{i}.attentions.{j}'
        lowerCAmelCase_      :				List[str]      =       f'input_blocks.{current_layer}.1'
        lowerCAmelCase_      :				Optional[int]      =       convert_attention(
            A__							,   A__							,   A__							,   A__							,   A__ )
        current_layer += 1

    if i != len(A__ ) - 1:
      lowerCAmelCase_      :				Union[str, Any]      =       f'down_blocks.{i}.downsamplers.0'
      lowerCAmelCase_      :				str      =       f'input_blocks.{current_layer}.0'
      lowerCAmelCase_      :				Optional[int]      =       convert_resnet(A__							,   A__							,   A__							,   A__ )
      current_layer += 1

    lowerCAmelCase_      :				List[str]      =       current_channels

  # hardcoded the mid-block for now
  lowerCAmelCase_      :				str      =       """mid_block.resnets.0"""
  lowerCAmelCase_      :				Optional[Any]      =       """middle_block.0"""
  lowerCAmelCase_      :				int      =       convert_resnet(A__							,   A__							,   A__							,   A__ )
  lowerCAmelCase_      :				Dict      =       """mid_block.attentions.0"""
  lowerCAmelCase_      :				str      =       """middle_block.1"""
  lowerCAmelCase_      :				List[Any]      =       convert_attention(A__							,   A__							,   A__							,   A__							,   A__ )
  lowerCAmelCase_      :				Optional[int]      =       """mid_block.resnets.1"""
  lowerCAmelCase_      :				Tuple      =       """middle_block.2"""
  lowerCAmelCase_      :				Tuple      =       convert_resnet(A__							,   A__							,   A__							,   A__ )

  lowerCAmelCase_      :				Any      =       0
  lowerCAmelCase_      :				Tuple      =       unet_config["""up_block_types"""]

  for i, layer_type in enumerate(A__ ):
    if layer_type == "ResnetUpsampleBlock2D":
      for j in range(layers_per_block + 1 ):
        lowerCAmelCase_      :				Optional[Any]      =       f'up_blocks.{i}.resnets.{j}'
        lowerCAmelCase_      :				str      =       f'output_blocks.{current_layer}.0'
        lowerCAmelCase_      :				Dict      =       convert_resnet(A__							,   A__							,   A__							,   A__							,   has_skip=A__ )
        current_layer += 1

      if i != len(A__ ) - 1:
        lowerCAmelCase_      :				Any      =       f'up_blocks.{i}.upsamplers.0'
        lowerCAmelCase_      :				Dict      =       f'output_blocks.{current_layer-1}.1'
        lowerCAmelCase_      :				List[Any]      =       convert_resnet(A__							,   A__							,   A__							,   A__ )
    elif layer_type == "AttnUpBlock2D":
      for j in range(layers_per_block + 1 ):
        lowerCAmelCase_      :				str      =       f'up_blocks.{i}.resnets.{j}'
        lowerCAmelCase_      :				Optional[int]      =       f'output_blocks.{current_layer}.0'
        lowerCAmelCase_      :				Any      =       convert_resnet(A__							,   A__							,   A__							,   A__							,   has_skip=A__ )
        lowerCAmelCase_      :				Tuple      =       f'up_blocks.{i}.attentions.{j}'
        lowerCAmelCase_      :				Dict      =       f'output_blocks.{current_layer}.1'
        lowerCAmelCase_      :				Union[str, Any]      =       convert_attention(
            A__							,   A__							,   A__							,   A__							,   A__ )
        current_layer += 1

      if i != len(A__ ) - 1:
        lowerCAmelCase_      :				Optional[int]      =       f'up_blocks.{i}.upsamplers.0'
        lowerCAmelCase_      :				Tuple      =       f'output_blocks.{current_layer-1}.2'
        lowerCAmelCase_      :				str      =       convert_resnet(A__							,   A__							,   A__							,   A__ )

  lowerCAmelCase_      :				Union[str, Any]      =       checkpoint["""out.0.weight"""]
  lowerCAmelCase_      :				Any      =       checkpoint["""out.0.bias"""]
  lowerCAmelCase_      :				str      =       checkpoint["""out.2.weight"""]
  lowerCAmelCase_      :				List[Any]      =       checkpoint["""out.2.bias"""]

  return new_checkpoint


if __name__ == "__main__":
  __A :  Optional[Any]    							=				argparse.ArgumentParser()

  parser.add_argument("--unet_path", default=None, type=str, required=True, help="Path to the unet.pt to convert.")
  parser.add_argument(
      "--dump_path", default=None, type=str, required=True, help="Path to output the converted UNet model."
  )
  parser.add_argument("--class_cond", default=True, type=str, help="Whether the model is class-conditional.")

  __A :  Optional[int]    							=				parser.parse_args()
  __A :  List[Any]    							=				strabool(args.class_cond)

  __A :  str    							=				os.path.basename(args.unet_path)
  print(F'''Checkpoint: {ckpt_name}''')

  # Get U-Net config
  if "imagenet64" in ckpt_name:
    __A :  List[str]    							=				IMAGENET_64_UNET_CONFIG
  elif "256" in ckpt_name and (("bedroom" in ckpt_name) or ("cat" in ckpt_name)):
    __A :  int    							=				LSUN_256_UNET_CONFIG
  elif "test" in ckpt_name:
    __A :  Union[str, Any]    							=				TEST_UNET_CONFIG
  else:
    raise ValueError(F'''Checkpoint type {ckpt_name} is not currently supported.''')

  if not args.class_cond:
    __A :  List[str]    							=				None

  __A :  Dict    							=				con_pt_to_diffuser(args.unet_path, unet_config)

  __A :  Tuple    							=				UNetaDModel(**unet_config)
  image_unet.load_state_dict(converted_unet_ckpt)

  # Get scheduler config
  if "cd" in ckpt_name or "test" in ckpt_name:
    __A :  int    							=				CD_SCHEDULER_CONFIG
  elif "ct" in ckpt_name and "imagenet64" in ckpt_name:
    __A :  Union[str, Any]    							=				CT_IMAGENET_64_SCHEDULER_CONFIG
  elif "ct" in ckpt_name and "256" in ckpt_name and (("bedroom" in ckpt_name) or ("cat" in ckpt_name)):
    __A :  Optional[int]    							=				CT_LSUN_256_SCHEDULER_CONFIG
  else:
    raise ValueError(F'''Checkpoint type {ckpt_name} is not currently supported.''')

  __A :  Optional[Any]    							=				CMStochasticIterativeScheduler(**scheduler_config)

  __A :  Tuple    							=				ConsistencyModelPipeline(unet=image_unet, scheduler=cm_scheduler)
  consistency_model.save_pretrained(args.dump_path)







'''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 get_down_block, get_mid_block, get_out_block, get_up_block






@dataclass
class        __snake_case	(       _SCREAMING_SNAKE_CASE):







    """simple docstring"""



    lowercase       			= 42







class        __snake_case	(       _SCREAMING_SNAKE_CASE     ,_SCREAMING_SNAKE_CASE):







    """simple docstring"""



    @register_to_config
    def __init__(       self   :  Optional[int]   ,						lowerCamelCase   :  int = 6_55_36   ,						lowerCamelCase   :  Optional[int] = None   ,						lowerCamelCase   :  int = 2   ,						lowerCamelCase   :  int = 2   ,						lowerCamelCase   :  int = 0   ,						lowerCamelCase   :  str = "fourier"   ,						lowerCamelCase   :  bool = True   ,						lowerCamelCase   :  bool = False   ,						lowerCamelCase   :  float = 0.0   ,						lowerCamelCase   :  Tuple[str] = ("DownBlock1DNoSkip", "DownBlock1D", "AttnDownBlock1D")   ,						lowerCamelCase   :  Tuple[str] = ("AttnUpBlock1D", "UpBlock1D", "UpBlock1DNoSkip")   ,						lowerCamelCase   :  Tuple[str] = "UNetMidBlock1D"   ,						lowerCamelCase   :  str = None   ,						lowerCamelCase   :  Tuple[int] = (32, 32, 64)   ,						lowerCamelCase   :  str = None   ,						lowerCamelCase   :  int = 8   ,						lowerCamelCase   :  int = 1   ,						lowerCamelCase   :  bool = False   ,						)       ->  List[Any]:
      super().__init__()
      lowerCAmelCase_      :				Optional[Any]      =       sample_size

      # time
      if time_embedding_type == "fourier":
        lowerCAmelCase_      :				int      =       GaussianFourierProjection(
            embedding_size=8   ,						set_W_to_weight=lowerCamelCase   ,						log=lowerCamelCase   ,						flip_sin_to_cos=lowerCamelCase		)
        lowerCAmelCase_      :				List[Any]      =       2 * block_out_channels[0]
      elif time_embedding_type == "positional":
        lowerCAmelCase_      :				Optional[int]      =       Timesteps(
            block_out_channels[0]   ,						flip_sin_to_cos=lowerCamelCase   ,						downscale_freq_shift=lowerCamelCase		)
        lowerCAmelCase_      :				Union[str, Any]      =       block_out_channels[0]

      if use_timestep_embedding:
        lowerCAmelCase_      :				List[str]      =       block_out_channels[0] * 4
        lowerCAmelCase_      :				List[str]      =       TimestepEmbedding(
            in_channels=lowerCamelCase   ,						time_embed_dim=lowerCamelCase   ,						act_fn=lowerCamelCase   ,						out_dim=block_out_channels[0]   ,						)

      lowerCAmelCase_      :				str      =       nn.ModuleList([]		)
      lowerCAmelCase_      :				Tuple      =       None
      lowerCAmelCase_      :				str      =       nn.ModuleList([]		)
      lowerCAmelCase_      :				List[str]      =       None

      # down
      lowerCAmelCase_      :				List[str]      =       in_channels
      for i, down_block_type in enumerate(lowerCamelCase		):
        lowerCAmelCase_      :				Optional[Any]      =       output_channel
        lowerCAmelCase_      :				str      =       block_out_channels[i]

        if i == 0:
          input_channel += extra_in_channels

        lowerCAmelCase_      :				int      =       i == len(lowerCamelCase		) - 1

        lowerCAmelCase_      :				List[str]      =       get_down_block(
            lowerCamelCase   ,						num_layers=lowerCamelCase   ,						in_channels=lowerCamelCase   ,						out_channels=lowerCamelCase   ,						temb_channels=block_out_channels[0]   ,						add_downsample=not is_final_block or downsample_each_block   ,						)
        self.down_blocks.append(lowerCamelCase		)

      # mid
      lowerCAmelCase_      :				Dict      =       get_mid_block(
          lowerCamelCase   ,						in_channels=block_out_channels[-1]   ,						mid_channels=block_out_channels[-1]   ,						out_channels=block_out_channels[-1]   ,						embed_dim=block_out_channels[0]   ,						num_layers=lowerCamelCase   ,						add_downsample=lowerCamelCase   ,						)

      # up
      lowerCAmelCase_      :				List[str]      =       list(reversed(lowerCamelCase		)		)
      lowerCAmelCase_      :				str      =       reversed_block_out_channels[0]
      if out_block_type is None:
        lowerCAmelCase_      :				Optional[int]      =       out_channels
      else:
        lowerCAmelCase_      :				Optional[Any]      =       block_out_channels[0]

      for i, up_block_type in enumerate(lowerCamelCase		):
        lowerCAmelCase_      :				Any      =       output_channel
        lowerCAmelCase_      :				str      =       (
            reversed_block_out_channels[i + 1] if i < len(lowerCamelCase		) - 1 else final_upsample_channels
        )

        lowerCAmelCase_      :				int      =       i == len(lowerCamelCase		) - 1

        lowerCAmelCase_      :				Any      =       get_up_block(
            lowerCamelCase   ,						num_layers=lowerCamelCase   ,						in_channels=lowerCamelCase   ,						out_channels=lowerCamelCase   ,						temb_channels=block_out_channels[0]   ,						add_upsample=not is_final_block   ,						)
        self.up_blocks.append(lowerCamelCase		)
        lowerCAmelCase_      :				Optional[int]      =       output_channel

      # out
      lowerCAmelCase_      :				str      =       norm_num_groups if norm_num_groups is not None else min(block_out_channels[0] // 4   ,						32		)
      lowerCAmelCase_      :				Union[str, Any]      =       get_out_block(
          out_block_type=lowerCamelCase   ,						num_groups_out=lowerCamelCase   ,						embed_dim=block_out_channels[0]   ,						out_channels=lowerCamelCase   ,						act_fn=lowerCamelCase   ,						fc_dim=block_out_channels[-1] // 4   ,						)





    def __lowercase       (       self   :  List[Any]   ,						lowerCamelCase   :  torch.FloatTensor   ,						lowerCamelCase   :  Union[torch.Tensor, float, int]   ,						lowerCamelCase   :  bool = True   ,						)       ->  Union[UNetaDOutput, Tuple]:
      lowerCAmelCase_      :				Optional[Any]      =       timestep
      if not torch.is_tensor(lowerCamelCase		):
        lowerCAmelCase_      :				Any      =       torch.tensor([timesteps]   ,						dtype=torch.long   ,						device=sample.device		)
      elif torch.is_tensor(lowerCamelCase		) and len(timesteps.shape		) == 0:
        lowerCAmelCase_      :				Dict      =       timesteps[None].to(sample.device		)

      lowerCAmelCase_      :				int      =       self.time_proj(lowerCamelCase		)
      if self.config.use_timestep_embedding:
        lowerCAmelCase_      :				int      =       self.time_mlp(lowerCamelCase		)
      else:
        lowerCAmelCase_      :				Tuple      =       timestep_embed[..., None]
        lowerCAmelCase_      :				Dict      =       timestep_embed.repeat([1, 1, sample.shape[2]]		).to(sample.dtype		)
        lowerCAmelCase_      :				Union[str, Any]      =       timestep_embed.broadcast_to((sample.shape[:1] + timestep_embed.shape[1:])		)

      # 2. down
      lowerCAmelCase_      :				Optional[Any]      =       ()
      for downsample_block in self.down_blocks:
        lowerCAmelCase_,							lowerCAmelCase_      :				Any      =       downsample_block(hidden_states=lowerCamelCase   ,						temb=lowerCamelCase		)
        down_block_res_samples += res_samples

      # 3. mid
      if self.mid_block:
        lowerCAmelCase_      :				int      =       self.mid_block(lowerCamelCase   ,						lowerCamelCase		)

      # 4. up
      for i, upsample_block in enumerate(self.up_blocks		):
        lowerCAmelCase_      :				str      =       down_block_res_samples[-1:]
        lowerCAmelCase_      :				Union[str, Any]      =       down_block_res_samples[:-1]
        lowerCAmelCase_      :				List[str]      =       upsample_block(lowerCamelCase   ,						res_hidden_states_tuple=lowerCamelCase   ,						temb=lowerCamelCase		)

      # 5. post-process
      if self.out_block:
        lowerCAmelCase_      :				Union[str, Any]      =       self.out_block(lowerCamelCase   ,						lowerCamelCase		)

      if not return_dict:
        return (sample,)

      return UNetaDOutput(sample=lowerCamelCase		)



