




from dataclasses import dataclass
from typing import Optional

import numpy as np
import torch
import torch.nn as nn

from ..utils import BaseOutput, is_torch_version, randn_tensor
from .attention_processor import SpatialNorm
from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block






@dataclass
class  _lowerCAmelCase     (  _lowercase	):
      A__		     =		42






class  _lowerCAmelCase     (  nn.Module	):

      def __init__(   self      ,				__UpperCAmelCase=3      ,				__UpperCAmelCase=3      ,				__UpperCAmelCase=("DownEncoderBlock2D",)      ,				__UpperCAmelCase=(64,)      ,				__UpperCAmelCase=2      ,				__UpperCAmelCase=32      ,				__UpperCAmelCase="silu"      ,				__UpperCAmelCase=True      ,				):
        super().__init__()
        lowerCAmelCase__				:  Optional[Any]		       =     layers_per_block

        lowerCAmelCase__				:  Optional[int]		       =     torch.nn.Convad(
            __UpperCAmelCase      ,				block_out_channels[0]      ,				kernel_size=3      ,				stride=1      ,				padding=1      ,				)

        lowerCAmelCase__				:  Dict		       =     None
        lowerCAmelCase__				:  List[Any]		       =     nn.ModuleList([]		)

        # down
        lowerCAmelCase__				:  List[str]		       =     block_out_channels[0]
        for i, down_block_type in enumerate(__UpperCAmelCase		):
          lowerCAmelCase__				:  Union[str, Any]		       =     output_channel
          lowerCAmelCase__				:  str		       =     block_out_channels[i]
          lowerCAmelCase__				:  Optional[Any]		       =     i == len(__UpperCAmelCase		) - 1

          lowerCAmelCase__				:  Optional[Any]		       =     get_down_block(
              __UpperCAmelCase      ,				num_layers=self.layers_per_block      ,				in_channels=__UpperCAmelCase      ,				out_channels=__UpperCAmelCase      ,				add_downsample=not is_final_block      ,				resnet_eps=1e-6      ,				downsample_padding=0      ,				resnet_act_fn=__UpperCAmelCase      ,				resnet_groups=__UpperCAmelCase      ,				attention_head_dim=__UpperCAmelCase      ,				temb_channels=__UpperCAmelCase      ,				)
          self.down_blocks.append(__UpperCAmelCase		)

        # mid
        lowerCAmelCase__				:  Optional[int]		       =     UNetMidBlockaD(
            in_channels=block_out_channels[-1]      ,				resnet_eps=1e-6      ,				resnet_act_fn=__UpperCAmelCase      ,				output_scale_factor=1      ,				resnet_time_scale_shift='''default'''      ,				attention_head_dim=block_out_channels[-1]      ,				resnet_groups=__UpperCAmelCase      ,				temb_channels=__UpperCAmelCase      ,				)

        # out
        lowerCAmelCase__				:  int		       =     nn.GroupNorm(num_channels=block_out_channels[-1]      ,				num_groups=__UpperCAmelCase      ,				eps=1e-6		)
        lowerCAmelCase__				:  Union[str, Any]		       =     nn.SiLU()

        lowerCAmelCase__				:  List[str]		       =     2 * out_channels if double_z else out_channels
        lowerCAmelCase__				:  int		       =     nn.Convad(block_out_channels[-1]      ,				__UpperCAmelCase      ,				3      ,				padding=1		)

        lowerCAmelCase__				:  int		       =     False







      def 	__magic_name__(   self      ,				__UpperCAmelCase		):
        lowerCAmelCase__				:  Tuple		       =     x
        lowerCAmelCase__				:  List[str]		       =     self.conv_in(__UpperCAmelCase		)

        if self.training and self.gradient_checkpointing:

          def create_custom_forward(__UpperCAmelCase		):
            def custom_forward(*__UpperCAmelCase		):
              return module(*__UpperCAmelCase		)

            return custom_forward

          # down
          if is_torch_version('''>='''      ,				'''1.11.0'''		):
            for down_block in self.down_blocks:
              lowerCAmelCase__				:  Any		       =     torch.utils.checkpoint.checkpoint(
                  create_custom_forward(__UpperCAmelCase		)      ,				__UpperCAmelCase      ,				use_reentrant=__UpperCAmelCase		)
            # middle
            lowerCAmelCase__				:  Dict		       =     torch.utils.checkpoint.checkpoint(
                create_custom_forward(self.mid_block		)      ,				__UpperCAmelCase      ,				use_reentrant=__UpperCAmelCase		)
          else:
            for down_block in self.down_blocks:
              lowerCAmelCase__				:  List[str]		       =     torch.utils.checkpoint.checkpoint(create_custom_forward(__UpperCAmelCase		)      ,				__UpperCAmelCase		)
            # middle
            lowerCAmelCase__				:  Optional[int]		       =     torch.utils.checkpoint.checkpoint(create_custom_forward(self.mid_block		)      ,				__UpperCAmelCase		)

        else:
          # down
          for down_block in self.down_blocks:
            lowerCAmelCase__				:  Optional[Any]		       =     down_block(__UpperCAmelCase		)

          # middle
          lowerCAmelCase__				:  Union[str, Any]		       =     self.mid_block(__UpperCAmelCase		)

        # post-process
        lowerCAmelCase__				:  Optional[Any]		       =     self.conv_norm_out(__UpperCAmelCase		)
        lowerCAmelCase__				:  Optional[int]		       =     self.conv_act(__UpperCAmelCase		)
        lowerCAmelCase__				:  Any		       =     self.conv_out(__UpperCAmelCase		)

        return sample






class  _lowerCAmelCase     (  nn.Module	):

      def __init__(   self      ,				__UpperCAmelCase=3      ,				__UpperCAmelCase=3      ,				__UpperCAmelCase=("UpDecoderBlock2D",)      ,				__UpperCAmelCase=(64,)      ,				__UpperCAmelCase=2      ,				__UpperCAmelCase=32      ,				__UpperCAmelCase="silu"      ,				__UpperCAmelCase="group"      ,				):
        super().__init__()
        lowerCAmelCase__				:  Dict		       =     layers_per_block

        lowerCAmelCase__				:  List[Any]		       =     nn.Convad(
            __UpperCAmelCase      ,				block_out_channels[-1]      ,				kernel_size=3      ,				stride=1      ,				padding=1      ,				)

        lowerCAmelCase__				:  int		       =     None
        lowerCAmelCase__				:  Any		       =     nn.ModuleList([]		)

        lowerCAmelCase__				:  str		       =     in_channels if norm_type == '''spatial''' else None

        # mid
        lowerCAmelCase__				:  Tuple		       =     UNetMidBlockaD(
            in_channels=block_out_channels[-1]      ,				resnet_eps=1e-6      ,				resnet_act_fn=__UpperCAmelCase      ,				output_scale_factor=1      ,				resnet_time_scale_shift='''default''' if norm_type == '''group''' else norm_type      ,				attention_head_dim=block_out_channels[-1]      ,				resnet_groups=__UpperCAmelCase      ,				temb_channels=__UpperCAmelCase      ,				)

        # up
        lowerCAmelCase__				:  Optional[int]		       =     list(reversed(__UpperCAmelCase		)		)
        lowerCAmelCase__				:  List[str]		       =     reversed_block_out_channels[0]
        for i, up_block_type in enumerate(__UpperCAmelCase		):
          lowerCAmelCase__				:  List[str]		       =     output_channel
          lowerCAmelCase__				:  Union[str, Any]		       =     reversed_block_out_channels[i]

          lowerCAmelCase__				:  Union[str, Any]		       =     i == len(__UpperCAmelCase		) - 1

          lowerCAmelCase__				:  Optional[Any]		       =     get_up_block(
              __UpperCAmelCase      ,				num_layers=self.layers_per_block + 1      ,				in_channels=__UpperCAmelCase      ,				out_channels=__UpperCAmelCase      ,				prev_output_channel=__UpperCAmelCase      ,				add_upsample=not is_final_block      ,				resnet_eps=1e-6      ,				resnet_act_fn=__UpperCAmelCase      ,				resnet_groups=__UpperCAmelCase      ,				attention_head_dim=__UpperCAmelCase      ,				temb_channels=__UpperCAmelCase      ,				resnet_time_scale_shift=__UpperCAmelCase      ,				)
          self.up_blocks.append(__UpperCAmelCase		)
          lowerCAmelCase__				:  Optional[Any]		       =     output_channel

        # out
        if norm_type == "spatial":
          lowerCAmelCase__				:  str		       =     SpatialNorm(block_out_channels[0]      ,				__UpperCAmelCase		)
        else:
          lowerCAmelCase__				:  Optional[int]		       =     nn.GroupNorm(num_channels=block_out_channels[0]      ,				num_groups=__UpperCAmelCase      ,				eps=1e-6		)
        lowerCAmelCase__				:  Any		       =     nn.SiLU()
        lowerCAmelCase__				:  Any		       =     nn.Convad(block_out_channels[0]      ,				__UpperCAmelCase      ,				3      ,				padding=1		)

        lowerCAmelCase__				:  Optional[int]		       =     False







      def 	__magic_name__(   self      ,				__UpperCAmelCase      ,				__UpperCAmelCase=None		):
        lowerCAmelCase__				:  Optional[int]		       =     z
        lowerCAmelCase__				:  Optional[Any]		       =     self.conv_in(__UpperCAmelCase		)

        lowerCAmelCase__				:  List[Any]		       =     next(iter(self.up_blocks.parameters()		)		).dtype
        if self.training and self.gradient_checkpointing:

          def create_custom_forward(__UpperCAmelCase		):
            def custom_forward(*__UpperCAmelCase		):
              return module(*__UpperCAmelCase		)

            return custom_forward

          if is_torch_version('''>='''      ,				'''1.11.0'''		):
            # middle
            lowerCAmelCase__				:  Tuple		       =     torch.utils.checkpoint.checkpoint(
                create_custom_forward(self.mid_block		)      ,				__UpperCAmelCase      ,				__UpperCAmelCase      ,				use_reentrant=__UpperCAmelCase		)
            lowerCAmelCase__				:  str		       =     sample.to(__UpperCAmelCase		)

            # up
            for up_block in self.up_blocks:
              lowerCAmelCase__				:  Optional[int]		       =     torch.utils.checkpoint.checkpoint(
                  create_custom_forward(__UpperCAmelCase		)      ,				__UpperCAmelCase      ,				__UpperCAmelCase      ,				use_reentrant=__UpperCAmelCase		)
          else:
            # middle
            lowerCAmelCase__				:  str		       =     torch.utils.checkpoint.checkpoint(
                create_custom_forward(self.mid_block		)      ,				__UpperCAmelCase      ,				__UpperCAmelCase		)
            lowerCAmelCase__				:  str		       =     sample.to(__UpperCAmelCase		)

            # up
            for up_block in self.up_blocks:
              lowerCAmelCase__				:  Optional[Any]		       =     torch.utils.checkpoint.checkpoint(create_custom_forward(__UpperCAmelCase		)      ,				__UpperCAmelCase      ,				__UpperCAmelCase		)
        else:
          # middle
          lowerCAmelCase__				:  int		       =     self.mid_block(__UpperCAmelCase      ,				__UpperCAmelCase		)
          lowerCAmelCase__				:  Any		       =     sample.to(__UpperCAmelCase		)

          # up
          for up_block in self.up_blocks:
            lowerCAmelCase__				:  Optional[Any]		       =     up_block(__UpperCAmelCase      ,				__UpperCAmelCase		)

        # post-process
        if latent_embeds is None:
          lowerCAmelCase__				:  List[Any]		       =     self.conv_norm_out(__UpperCAmelCase		)
        else:
          lowerCAmelCase__				:  Tuple		       =     self.conv_norm_out(__UpperCAmelCase      ,				__UpperCAmelCase		)
        lowerCAmelCase__				:  Tuple		       =     self.conv_act(__UpperCAmelCase		)
        lowerCAmelCase__				:  Tuple		       =     self.conv_out(__UpperCAmelCase		)

        return sample






class  _lowerCAmelCase     (  nn.Module	):

      def __init__(   self      ,				__UpperCAmelCase      ,				__UpperCAmelCase      ,				__UpperCAmelCase      ,				__UpperCAmelCase=None      ,				__UpperCAmelCase="random"      ,				__UpperCAmelCase=False      ,				__UpperCAmelCase=True		):
        super().__init__()
        lowerCAmelCase__				:  Union[str, Any]		       =     n_e
        lowerCAmelCase__				:  Tuple		       =     vq_embed_dim
        lowerCAmelCase__				:  Dict		       =     beta
        lowerCAmelCase__				:  int		       =     legacy

        lowerCAmelCase__				:  List[str]		       =     nn.Embedding(self.n_e      ,				self.vq_embed_dim		)
        self.embedding.weight.data.uniform_(-1.0 / self.n_e      ,				1.0 / self.n_e		)

        lowerCAmelCase__				:  List[Any]		       =     remap
        if self.remap is not None:
          self.register_buffer('''used'''      ,				torch.tensor(np.load(self.remap		)		)		)
          lowerCAmelCase__				:  Tuple		       =     self.used.shape[0]
          lowerCAmelCase__				:  Union[str, Any]		       =     unknown_index  # "random" or "extra" or integer
          if self.unknown_index == "extra":
            lowerCAmelCase__				:  List[str]		       =     self.re_embed
            lowerCAmelCase__				:  Dict		       =     self.re_embed + 1
          print(
              f"""Remapping {self.n_e} indices to {self.re_embed} indices. """
              f"""Using {self.unknown_index} for unknown indices."""		)
        else:
          lowerCAmelCase__				:  Dict		       =     n_e

        lowerCAmelCase__				:  Optional[Any]		       =     sane_index_shape

      def 	__magic_name__(   self      ,				__UpperCAmelCase		):
        lowerCAmelCase__				:  Dict		       =     inds.shape
        assert len(__UpperCAmelCase		) > 1
        lowerCAmelCase__				:  str		       =     inds.reshape(ishape[0]      ,				-1		)
        lowerCAmelCase__				:  Union[str, Any]		       =     self.used.to(__UpperCAmelCase		)
        lowerCAmelCase__				:  Tuple		       =     (inds[:, :, None] == used[None, None, ...]).long()
        lowerCAmelCase__				:  List[str]		       =     match.argmax(-1		)
        lowerCAmelCase__				:  int		       =     match.sum(2		) < 1
        if self.unknown_index == "random":
          lowerCAmelCase__				:  Optional[int]		       =     torch.randint(0      ,				self.re_embed      ,				size=new[unknown].shape		).to(device=new.device		)
        else:
          lowerCAmelCase__				:  int		       =     self.unknown_index
        return new.reshape(__UpperCAmelCase		)

      def 	__magic_name__(   self      ,				__UpperCAmelCase		):
        lowerCAmelCase__				:  Dict		       =     inds.shape
        assert len(__UpperCAmelCase		) > 1
        lowerCAmelCase__				:  Optional[Any]		       =     inds.reshape(ishape[0]      ,				-1		)
        lowerCAmelCase__				:  str		       =     self.used.to(__UpperCAmelCase		)
        if self.re_embed > self.used.shape[0]:  # extra token
          lowerCAmelCase__				:  Any		       =     0  # simply set to zero
        lowerCAmelCase__				:  Dict		       =     torch.gather(used[None, :][inds.shape[0] * [0], :]      ,				1      ,				__UpperCAmelCase		)
        return back.reshape(__UpperCAmelCase		)

      def 	__magic_name__(   self      ,				__UpperCAmelCase		):
        # reshape z -> (batch, height, width, channel) and flatten
        lowerCAmelCase__				:  Any		       =     z.permute(0      ,				2      ,				3      ,				1		).contiguous()
        lowerCAmelCase__				:  Dict		       =     z.view(-1      ,				self.vq_embed_dim		)

        # distances from z to embeddings e_j (z - e)^2 = z^2 + e^2 - 2 e * z
        lowerCAmelCase__				:  Union[str, Any]		       =     torch.argmin(torch.cdist(__UpperCAmelCase      ,				self.embedding.weight		)      ,				dim=1		)

        lowerCAmelCase__				:  List[str]		       =     self.embedding(__UpperCAmelCase		).view(z.shape		)
        lowerCAmelCase__				:  Optional[Any]		       =     None
        lowerCAmelCase__				:  Optional[Any]		       =     None

        # compute loss for embedding
        if not self.legacy:
          lowerCAmelCase__				:  int		       =     self.beta * torch.mean((z_q.detach() - z) ** 2		) + torch.mean((z_q - z.detach()) ** 2		)
        else:
          lowerCAmelCase__				:  int		       =     torch.mean((z_q.detach() - z) ** 2		) + self.beta * torch.mean((z_q - z.detach()) ** 2		)

        # preserve gradients
        lowerCAmelCase__				:  List[str]		       =     z + (z_q - z).detach()

        # reshape back to match original input shape
        lowerCAmelCase__				:  Dict		       =     z_q.permute(0      ,				3      ,				1      ,				2		).contiguous()

        if self.remap is not None:
          lowerCAmelCase__				:  Union[str, Any]		       =     min_encoding_indices.reshape(z.shape[0]      ,				-1		)  # add batch axis
          lowerCAmelCase__				:  List[str]		       =     self.remap_to_used(__UpperCAmelCase		)
          lowerCAmelCase__				:  Dict		       =     min_encoding_indices.reshape(-1      ,				1		)  # flatten

        if self.sane_index_shape:
          lowerCAmelCase__				:  Tuple		       =     min_encoding_indices.reshape(z_q.shape[0]      ,				z_q.shape[2]      ,				z_q.shape[3]		)

        return z_q, loss, (perplexity, min_encodings, min_encoding_indices)







      def 	__magic_name__(   self      ,				__UpperCAmelCase      ,				__UpperCAmelCase		):
        # shape specifying (batch, height, width, channel)
        if self.remap is not None:
          lowerCAmelCase__				:  str		       =     indices.reshape(shape[0]      ,				-1		)  # add batch axis
          lowerCAmelCase__				:  List[str]		       =     self.unmap_to_all(__UpperCAmelCase		)
          lowerCAmelCase__				:  List[str]		       =     indices.reshape(-1		)  # flatten again

        # get quantized latent vectors
        lowerCAmelCase__				:  Dict		       =     self.embedding(__UpperCAmelCase		)

        if shape is not None:
          lowerCAmelCase__				:  Dict		       =     z_q.view(__UpperCAmelCase		)
          # reshape back to match original input shape
          lowerCAmelCase__				:  Tuple		       =     z_q.permute(0      ,				3      ,				1      ,				2		).contiguous()

        return z_q






class  _lowerCAmelCase     (  _lowercase	):

      def __init__(   self      ,				__UpperCAmelCase      ,				__UpperCAmelCase=False		):
        lowerCAmelCase__				:  int		       =     parameters
        lowerCAmelCase__       ,			lowerCAmelCase__				:  Union[str, Any]		       =     torch.chunk(__UpperCAmelCase      ,				2      ,				dim=1		)
        lowerCAmelCase__				:  Optional[Any]		       =     torch.clamp(self.logvar      ,				-30.0      ,				20.0		)
        lowerCAmelCase__				:  Any		       =     deterministic
        lowerCAmelCase__				:  Dict		       =     torch.exp(0.5 * self.logvar		)
        lowerCAmelCase__				:  Optional[int]		       =     torch.exp(self.logvar		)
        if self.deterministic:
          lowerCAmelCase__				:  Dict		       =     torch.zeros_like(
              self.mean      ,				device=self.parameters.device      ,				dtype=self.parameters.dtype		)

      def 	__magic_name__(   self      ,				__UpperCAmelCase = None		):
        # make sure sample is on the same device as the parameters and has same dtype
        lowerCAmelCase__				:  Optional[int]		       =     randn_tensor(
            self.mean.shape      ,				generator=__UpperCAmelCase      ,				device=self.parameters.device      ,				dtype=self.parameters.dtype		)
        lowerCAmelCase__				:  List[Any]		       =     self.mean + self.std * sample
        return x

      def 	__magic_name__(   self      ,				__UpperCAmelCase=None		):
        if self.deterministic:
          return torch.Tensor([0.0]		)
        else:
          if other is None:
            return 0.5 * torch.sum(torch.pow(self.mean      ,				2		) + self.var - 1.0 - self.logvar      ,				dim=[1, 2, 3]		)
          else:
            return 0.5 * torch.sum(
                torch.pow(self.mean - other.mean      ,				2		) / other.var
                + self.var / other.var
                - 1.0
                - self.logvar
                + other.logvar      ,				dim=[1, 2, 3]      ,				)

      def 	__magic_name__(   self      ,				__UpperCAmelCase      ,				__UpperCAmelCase=[1, 2, 3]		):
        if self.deterministic:
          return torch.Tensor([0.0]		)
        lowerCAmelCase__				:  Union[str, Any]		       =     np.log(2.0 * np.pi		)
        return 0.5 * torch.sum(logtwopi + self.logvar + torch.pow(sample - self.mean      ,				2		) / self.var      ,				dim=__UpperCAmelCase		)







      def 	__magic_name__(   self		):
        return self.mean







def      __lowerCAmelCase			(					UpperCamelCase      )     ->	None:
  lowerCAmelCase__				:  Dict		       =     generate_pascal_triangle(UpperCamelCase      )
  for row_idx in range(UpperCamelCase      ):
    # Print left spaces
    for _ in range(num_rows - row_idx - 1      ):
      print(end=''' '''      )
    # Print row values
    for col_idx in range(row_idx + 1      ):
      if col_idx != row_idx:
        print(triangle[row_idx][col_idx]	,      end=''' '''      )
      else:
        print(triangle[row_idx][col_idx]	,      end=''''''      )
    print()



def      __lowerCAmelCase			(					UpperCamelCase      )     ->	list[list[int]]:

  if not isinstance(UpperCamelCase	,      UpperCamelCase      ):
    raise TypeError('''The input value of \'num_rows\' should be \'int\''''      )

  if num_rows == 0:
    return []
  elif num_rows < 0:
    raise ValueError(
        '''The input value of \'num_rows\' should be greater than or equal to 0'''      )

  lowerCAmelCase__				:  list[list[int]]		       =     []
  for current_row_idx in range(UpperCamelCase      ):
    lowerCAmelCase__				:  List[str]		       =     populate_current_row(UpperCamelCase	,      UpperCamelCase      )
    triangle.append(UpperCamelCase      )
  return triangle



def      __lowerCAmelCase			(					UpperCamelCase	,      UpperCamelCase      )     ->	list[int]:
  lowerCAmelCase__				:  Optional[Any]		       =     [-1] * (current_row_idx + 1)
  # first and last elements of current row are equal to 1
  lowerCAmelCase__       ,			lowerCAmelCase__				:  int		       =     1, 1
  for current_col_idx in range(1	,      UpperCamelCase      ):
    calculate_current_element(
        UpperCamelCase	,      UpperCamelCase	,      UpperCamelCase	,      UpperCamelCase      )
  return current_row



def      __lowerCAmelCase			(					UpperCamelCase	,      UpperCamelCase	,      UpperCamelCase	,      UpperCamelCase	,      )     ->	None:
  lowerCAmelCase__				:  Optional[int]		       =     triangle[current_row_idx - 1][current_col_idx - 1]
  lowerCAmelCase__				:  List[str]		       =     triangle[current_row_idx - 1][current_col_idx]
  lowerCAmelCase__				:  List[Any]		       =     above_to_left_elt + above_to_right_elt



def      __lowerCAmelCase			(					UpperCamelCase      )     ->	list[list[int]]:

  if not isinstance(UpperCamelCase	,      UpperCamelCase      ):
    raise TypeError('''The input value of \'num_rows\' should be \'int\''''      )

  if num_rows == 0:
    return []
  elif num_rows < 0:
    raise ValueError(
        '''The input value of \'num_rows\' should be greater than or equal to 0'''      )

  lowerCAmelCase__				:  list[list[int]]		       =     [[1]]

  for row_index in range(1	,      UpperCamelCase      ):
    lowerCAmelCase__				:  Optional[int]		       =     [0] + result[-1] + [0]
    lowerCAmelCase__				:  List[str]		       =     row_index + 1
    # Calculate the number of distinct elements in a row
    lowerCAmelCase__				:  Tuple		       =     sum(divmod(UpperCamelCase	,      2      )      )
    lowerCAmelCase__				:  Tuple		       =     [
        temp_row[i - 1] + temp_row[i] for i in range(1	,      distinct_elements + 1      )
    ]
    lowerCAmelCase__				:  int		       =     row_first_half[: (row_index + 1) // 2]
    row_second_half.reverse()
    lowerCAmelCase__				:  Dict		       =     row_first_half + row_second_half
    result.append(UpperCamelCase      )

  return result



def      __lowerCAmelCase			(					)     ->	None:
  from collections.abc import Callable
  from timeit import timeit

  def benchmark_a_function(UpperCamelCase	,      UpperCamelCase      ) -> None:
    lowerCAmelCase__				:  Tuple		       =     F"""{func.__name__}({value})"""
    lowerCAmelCase__				:  Dict		       =     timeit(F"""__main__.{call}"""	,      setup='''import __main__'''      )
    # print(f"{call:38} = {func(value)} -- {timing:.4f} seconds")
    print(F"""{call:38} -- {timing:.4f} seconds"""      )

  for value in range(15      ):  # (1, 7, 14):
    for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):
      benchmark_a_function(UpperCamelCase	,      UpperCamelCase      )
    print()


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     benchmark()

