




'''simple docstring'''







import argparse
import json
import os

import fairseq
import torch
from fairseq.data import Dictionary

from transformers import (
    WavaVecaConformerConfig,
    WavaVecaConformerForCTC,
    WavaVecaConformerForPreTraining,
    WavaVecaCTCTokenizer,
    WavaVecaFeatureExtractor,
    WavaVecaProcessor,
    logging,
)


logging.set_verbosity_info()
A     =logging.get_logger(__name__)

A     ={
    'post_extract_proj': 'feature_projection.projection',
    'encoder.pos_conv.0': 'encoder.pos_conv_embed.conv',
    'self_attn.linear_k': 'encoder.layers.*.self_attn.linear_k',
    'self_attn.linear_v': 'encoder.layers.*.self_attn.linear_v',
    'self_attn.linear_q': 'encoder.layers.*.self_attn.linear_q',
    'self_attn.pos_bias_u': 'encoder.layers.*.self_attn.pos_bias_u',
    'self_attn.pos_bias_v': 'encoder.layers.*.self_attn.pos_bias_v',
    'self_attn.linear_out': 'encoder.layers.*.self_attn.linear_out',
    'self_attn.linear_pos': 'encoder.layers.*.self_attn.linear_pos',
    'self_attn.rotary_emb': 'encoder.embed_positions',
    'self_attn_layer_norm': 'encoder.layers.*.self_attn_layer_norm',
    'conv_module.pointwise_conv1': 'encoder.layers.*.conv_module.pointwise_conv1',
    'conv_module.pointwise_conv2': 'encoder.layers.*.conv_module.pointwise_conv2',
    'conv_module.depthwise_conv': 'encoder.layers.*.conv_module.depthwise_conv',
    'conv_module.batch_norm': 'encoder.layers.*.conv_module.batch_norm',
    'conv_module.layer_norm': 'encoder.layers.*.conv_module.layer_norm',
    'ffn1.w_1': 'encoder.layers.*.ffn1.intermediate_dense',
    'ffn1.w_2': 'encoder.layers.*.ffn1.output_dense',
    'ffn1.layer_norm': 'encoder.layers.*.ffn1_layer_norm',
    'ffn2.w_1': 'encoder.layers.*.ffn2.intermediate_dense',
    'ffn2.w_2': 'encoder.layers.*.ffn2.output_dense',
    'ffn2.layer_norm': 'encoder.layers.*.ffn2_layer_norm',
    'final_layer_norm': 'encoder.layers.*.final_layer_norm',
    'encoder.layer_norm': 'encoder.layer_norm',
    'w2v_model.layer_norm': 'feature_projection.layer_norm',
    'quantizer.weight_proj': 'quantizer.weight_proj',
    'quantizer.vars': 'quantizer.codevectors',
    'project_q': 'project_q',
    'final_proj': 'project_hid',
    'w2v_encoder.proj': 'lm_head',
    'mask_emb': 'masked_spec_embed',
}
A     =[
    'lm_head',
    'quantizer.weight_proj',
    'quantizer.codevectors',
    'project_q',
    'project_hid',
]





def 						snake_case_							(_a	:							int    ,   _a	:							Optional[int]    ,   _a	:							int    ,   _a	:							List[Any]    ,   _a	:							Tuple     ):
    for attribute in key.split('''.'''     ):
        UpperCAmelCase			       =		getattr(_a    ,   _a     )

    if weight_type is not None:
        UpperCAmelCase			       =		getattr(_a    ,   _a     ).shape
    else:
        UpperCAmelCase			       =		hf_pointer.shape

    if hf_shape != value.shape:
        raise ValueError(
            F"Shape of hf {key + '.' + weight_type if weight_type is not None else ''} is {hf_shape}, but should be"
            F" {value.shape} for {full_name}"     )

    if weight_type == "weight":
        UpperCAmelCase			       =		value
    elif weight_type == "weight_g":
        UpperCAmelCase			       =		value
    elif weight_type == "weight_v":
        UpperCAmelCase			       =		value
    elif weight_type == "bias":
        UpperCAmelCase			       =		value
    elif weight_type == "running_mean":
        UpperCAmelCase			       =		value
    elif weight_type == "running_var":
        UpperCAmelCase			       =		value
    elif weight_type == "num_batches_tracked":
        UpperCAmelCase			       =		value
    elif weight_type == "inv_freq":
        UpperCAmelCase			       =		value
    else:
        UpperCAmelCase			       =		value

    logger.info(F"{key + '.' + weight_type if weight_type is not None else ''} was initialized from {full_name}."     )





def 						snake_case_							(_a	:							List[Any]    ,   _a	:							int    ,   _a	:							Dict     ):
    UpperCAmelCase			       =		[]
    UpperCAmelCase			       =		fairseq_model.state_dict()

    UpperCAmelCase			       =		hf_model.wavaveca_conformer.feature_extractor

    for name, value in fairseq_dict.items():
        UpperCAmelCase			       =		False
        if "conv_layers" in name:
            load_conv_layer(
                _a    ,   _a    ,   _a    ,   _a    ,   hf_model.config.feat_extract_norm == '''group'''    ,   )
            UpperCAmelCase			       =		True
        else:
            for key, mapped_key in MAPPING.items():
                UpperCAmelCase			       =		'''wav2vec2_conformer.''' + mapped_key if mapped_key not in TOP_LEVEL_KEYS else mapped_key
                if key in name or key.split('''w2v_model.'''     )[-1] == name.split('''.'''     )[0]:
                    UpperCAmelCase			       =		True
                    if "*" in mapped_key:
                        UpperCAmelCase			       =		name.split(_a     )[0].split('''.'''     )[-2]
                        UpperCAmelCase			       =		mapped_key.replace('''*'''    ,   _a     )
                    if "pos_bias_u" in name:
                        UpperCAmelCase			       =		None
                    elif "pos_bias_v" in name:
                        UpperCAmelCase			       =		None
                    elif "weight_g" in name:
                        UpperCAmelCase			       =		'''weight_g'''
                    elif "weight_v" in name:
                        UpperCAmelCase			       =		'''weight_v'''
                    elif "bias" in name:
                        UpperCAmelCase			       =		'''bias'''
                    elif "weight" in name:
                        # TODO: don't match quantizer.weight_proj
                        UpperCAmelCase			       =		'''weight'''
                    elif "running_mean" in name:
                        UpperCAmelCase			       =		'''running_mean'''
                    elif "inv_freq" in name:
                        UpperCAmelCase			       =		'''inv_freq'''
                    elif "running_var" in name:
                        UpperCAmelCase			       =		'''running_var'''
                    elif "num_batches_tracked" in name:
                        UpperCAmelCase			       =		'''num_batches_tracked'''
                    else:
                        UpperCAmelCase			       =		None
                    set_recursively(_a    ,   _a    ,   _a    ,   _a    ,   _a     )
                continue
        if not is_used:
            unused_weights.append(_a     )

    logger.warning(F"Unused weights: {unused_weights}"     )





def 						snake_case_							(_a	:							Any    ,   _a	:							int    ,   _a	:							str    ,   _a	:							Any    ,   _a	:							Dict     ):
    UpperCAmelCase			       =		full_name.split('''conv_layers.'''     )[-1]
    UpperCAmelCase			       =		name.split('''.'''     )
    UpperCAmelCase			       =		int(items[0]     )
    UpperCAmelCase			       =		int(items[1]     )

    if type_id == 0:
        if "bias" in name:
            if value.shape != feature_extractor.conv_layers[layer_id].conv.bias.data.shape:
                raise ValueError(
                    F"{full_name} has size {value.shape}, but"
                    F" {feature_extractor.conv_layers[layer_id].conv.bias.data.shape} was found."     )
            UpperCAmelCase			       =		value
            logger.info(F"Feat extract conv layer {layer_id} was initialized from {full_name}."     )
        elif "weight" in name:
            if value.shape != feature_extractor.conv_layers[layer_id].conv.weight.data.shape:
                raise ValueError(
                    F"{full_name} has size {value.shape}, but"
                    F" {feature_extractor.conv_layers[layer_id].conv.weight.data.shape} was found."     )
            UpperCAmelCase			       =		value
            logger.info(F"Feat extract conv layer {layer_id} was initialized from {full_name}."     )
    elif (type_id == 2 and not use_group_norm) or (type_id == 2 and layer_id == 0 and use_group_norm):
        if "bias" in name:
            if value.shape != feature_extractor.conv_layers[layer_id].layer_norm.bias.data.shape:
                raise ValueError(
                    F"{full_name} has size {value.shape}, but"
                    F" {feature_extractor.conv_layers[layer_id].layer_norm.bias.data.shape} was found."     )
            UpperCAmelCase			       =		value
            logger.info(F"Feat extract layer norm weight of layer {layer_id} was initialized from {full_name}."     )
        elif "weight" in name:
            if value.shape != feature_extractor.conv_layers[layer_id].layer_norm.weight.data.shape:
                raise ValueError(
                    F"{full_name} has size {value.shape}, but"
                    F" {feature_extractor.conv_layers[layer_id].layer_norm.weight.data.shape} was found."     )
            UpperCAmelCase			       =		value
            logger.info(F"Feat extract layer norm weight of layer {layer_id} was initialized from {full_name}."     )
    else:
        unused_weights.append(_a     )





@torch.no_grad()
def 						snake_case_							(_a	:							List[Any]    ,   _a	:							int    ,   _a	:							Any=None    ,   _a	:							List[str]=None    ,   _a	:							List[Any]=True     ):
    if config_path is not None:
        UpperCAmelCase			       =		WavaVecaConformerConfig.from_pretrained(_a    ,   hidden_act='''swish'''     )
    else:
        UpperCAmelCase			       =		WavaVecaConformerConfig()

    if "rope" in checkpoint_path:
        UpperCAmelCase			       =		'''rotary'''

    if is_finetuned:
        if dict_path:
            UpperCAmelCase			       =		Dictionary.load(_a     )

            # important change bos & pad token id since CTC symbol is <pad> and
            # not <s> as in fairseq
            UpperCAmelCase			       =		target_dict.pad_index
            UpperCAmelCase			       =		target_dict.bos_index
            UpperCAmelCase			       =		target_dict.eos_index
            UpperCAmelCase			       =		len(target_dict.symbols     )
            UpperCAmelCase			       =		os.path.join(_a    ,   '''vocab.json'''     )
            if not os.path.isdir(_a     ):
                logger.error('''--pytorch_dump_folder_path ({}) should be a directory'''.format(_a     )     )
                return
            os.makedirs(_a    ,   exist_ok=_a     )
            UpperCAmelCase			       =		target_dict.indices

            # fairseq has the <pad> and <s> switched
            UpperCAmelCase			       =		0
            UpperCAmelCase			       =		1
            with open(_a    ,   '''w'''    ,   encoding='''utf-8'''     ) as vocab_handle:
                json.dump(_a    ,   _a     )
            UpperCAmelCase			       =		WavaVecaCTCTokenizer(
                _a    ,   unk_token=target_dict.unk_word    ,   pad_token=target_dict.pad_word    ,   bos_token=target_dict.bos_word    ,   eos_token=target_dict.eos_word    ,   word_delimiter_token='''|'''    ,   do_lower_case=_a    ,   )
            UpperCAmelCase			       =		True if config.feat_extract_norm == '''layer''' else False
            UpperCAmelCase			       =		WavaVecaFeatureExtractor(
                feature_size=1    ,   sampling_rate=1_6_0_0_0    ,   padding_value=0    ,   do_normalize=_a    ,   return_attention_mask=_a    ,   )
            UpperCAmelCase			       =		WavaVecaProcessor(feature_extractor=_a    ,   tokenizer=_a     )
            processor.save_pretrained(_a     )

        UpperCAmelCase			       =		WavaVecaConformerForCTC(_a     )
    else:
        UpperCAmelCase			       =		WavaVecaConformerForPreTraining(_a     )

    if is_finetuned:
        UpperCAmelCase       ,     UpperCAmelCase       ,     UpperCAmelCase			       =		fairseq.checkpoint_utils.load_model_ensemble_and_task(
            [checkpoint_path]    ,   arg_overrides={'''data''': '''/'''.join(dict_path.split('''/'''     )[:-1]     )}     )
    else:
        UpperCAmelCase			       =		argparse.Namespace(task='''audio_pretraining'''     )
        UpperCAmelCase			       =		fairseq.tasks.setup_task(_a     )

        UpperCAmelCase       ,     UpperCAmelCase       ,     UpperCAmelCase			       =		fairseq.checkpoint_utils.load_model_ensemble_and_task([checkpoint_path]    ,   task=_a     )

    UpperCAmelCase			       =		model[0].eval()

    recursively_load_weights(_a    ,   _a    ,   not is_finetuned     )

    hf_wavavec.save_pretrained(_a     )


if __name__ == "__main__":
   A     =argparse.ArgumentParser()
   parser.add_argument('--pytorch_dump_folder_path', default=None, type=str, help='Path to the output PyTorch model.')
   parser.add_argument('--checkpoint_path', default=None, type=str, help='Path to fairseq checkpoint')
   parser.add_argument('--dict_path', default=None, type=str, help='Path to dict of fine-tuned model')
   parser.add_argument('--config_path', default=None, type=str, help='Path to hf config.json of model to convert')
   parser.add_argument(
       '--not_finetuned', action='store_true', help='Whether the model to convert is a fine-tuned model or not'
   )
   A     =parser.parse_args()
   convert_wavaveca_conformer_checkpoint(
       args.checkpoint_path, args.pytorch_dump_folder_path, args.config_path, args.dict_path, not args.not_finetuned
   )






import random

import torch
from huggingface_hub import HfApi

from diffusers import UNetaDModel


_lowerCamelCase       :				List[Any]       =			HfApi()

_lowerCamelCase       :				Dict       =			{}
# fmt: off
_lowerCamelCase       :				List[Any]       =			torch.tensor([
    -0.7_5_1_5, -1.6_8_8_3, 0.2_4_2_0, 0.0_3_0_0, 0.6_3_4_7, 1.3_4_3_3, -1.1_7_4_3, -3.7_4_6_7,
    1.2_3_4_2, -2.2_4_8_5, 0.4_6_3_6, 0.8_0_7_6, -0.7_9_9_1, 0.3_9_6_9, 0.8_4_9_8, 0.9_1_8_9,
    -1.8_8_8_7, -3.3_5_2_2, 0.7_6_3_9, 0.2_0_4_0, 0.6_2_7_1, -2.7_1_4_8, -1.6_3_1_6, 3.0_8_3_9,
    0.3_1_8_6, 0.2_7_2_1, -0.9_7_5_9, -1.2_4_6_1, 2.6_2_5_7, 1.3_5_5_7
])
_lowerCamelCase       :				int       =			torch.tensor([
    -2.3_6_3_9, -2.5_3_4_4, 0.0_0_5_4, -0.6_6_7_4, 1.5_9_9_0, 1.0_1_5_8, 0.3_1_2_4, -2.1_4_3_6,
    1.8_7_9_5, -2.5_4_2_9, -0.1_5_6_6, -0.3_9_7_3, 1.2_4_9_0, 2.6_4_4_7, 1.2_2_8_3, -0.5_2_0_8,
    -2.8_1_5_4, -3.5_1_1_9, 2.3_8_3_8, 1.2_0_3_3, 1.7_2_0_1, -2.1_2_5_6, -1.4_5_7_6, 2.7_9_4_8,
    2.4_2_0_4, -0.9_7_5_2, -1.2_5_4_6, 0.8_0_2_7, 3.2_7_5_8, 3.1_3_6_5
])
_lowerCamelCase       :				Optional[int]       =			torch.tensor([
    -0.6_5_3_1, -0.6_8_9_1, -0.3_1_7_2, -0.5_3_7_5, -0.9_1_4_0, -0.5_3_6_7, -0.1_1_7_5, -0.7_8_6_9,
    -0.3_8_0_8, -0.4_5_1_3, -0.2_0_9_8, -0.0_0_8_3, 0.3_1_8_3, 0.5_1_4_0, 0.2_2_4_7, -0.1_3_0_4,
    -0.1_3_0_2, -0.2_8_0_2, -0.2_0_8_4, -0.2_0_2_5, -0.4_9_6_7, -0.4_8_7_3, -0.0_8_6_1, 0.6_9_2_5,
    0.0_2_5_0, 0.1_2_9_0, -0.1_5_4_3, 0.6_3_1_6, 1.0_4_6_0, 1.4_9_4_3
])
_lowerCamelCase       :				Dict       =			torch.tensor([
    0.0_9_1_1, 0.1_1_0_7, 0.0_1_8_2, 0.0_4_3_5, -0.0_8_0_5, -0.0_6_0_8, 0.0_3_8_1, 0.2_1_7_2,
    -0.0_2_8_0, 0.1_3_2_7, -0.0_2_9_9, -0.0_2_5_5, -0.0_0_5_0, -0.1_1_7_0, -0.1_0_4_6, 0.0_3_0_9,
    0.1_3_6_7, 0.1_7_2_8, -0.0_5_3_3, -0.0_7_4_8, -0.0_5_3_4, 0.1_6_2_4, 0.0_3_8_4, -0.1_8_0_5,
    -0.0_7_0_7, 0.0_6_4_2, 0.0_2_2_0, -0.0_1_3_4, -0.1_3_3_3, -0.1_5_0_5
])
_lowerCamelCase       :				Dict       =			torch.tensor([
    0.1_3_2_1, 0.1_3_3_7, 0.0_4_4_0, 0.0_6_2_2, -0.0_5_9_1, -0.0_3_7_0, 0.0_5_0_3, 0.2_1_3_3,
    -0.0_1_7_7, 0.1_4_1_5, -0.0_1_1_6, -0.0_1_1_2, 0.0_0_4_4, -0.0_9_8_0, -0.0_7_8_9, 0.0_3_9_5,
    0.1_5_0_2, 0.1_7_8_5, -0.0_4_8_8, -0.0_5_1_4, -0.0_4_0_4, 0.1_5_3_9, 0.0_4_5_4, -0.1_5_5_9,
    -0.0_6_6_5, 0.0_6_5_9, 0.0_3_8_3, -0.0_0_0_5, -0.1_2_6_6, -0.1_3_8_6
])
_lowerCamelCase       :				List[Any]       =			torch.tensor([
    0.1_1_5_4, 0.1_2_1_8, 0.0_3_0_7, 0.0_5_2_6, -0.0_7_1_1, -0.0_5_4_1, 0.0_3_6_6, 0.2_0_7_8,
    -0.0_2_6_7, 0.1_3_1_7, -0.0_2_2_6, -0.0_1_9_3, -0.0_0_1_4, -0.1_0_5_5, -0.0_9_0_2, 0.0_3_3_0,
    0.1_3_9_1, 0.1_7_0_9, -0.0_5_6_2, -0.0_6_9_3, -0.0_5_6_0, 0.1_4_8_2, 0.0_3_8_1, -0.1_6_8_3,
    -0.0_6_8_1, 0.0_6_6_1, 0.0_3_3_1, -0.0_0_4_6, -0.1_2_6_8, -0.1_4_3_1
])
_lowerCamelCase       :				Dict       =			torch.tensor([
    0.1_1_9_2, 0.1_2_4_0, 0.0_4_1_4, 0.0_6_0_6, -0.0_5_5_7, -0.0_4_1_2, 0.0_4_3_0, 0.2_0_4_2,
    -0.0_2_0_0, 0.1_3_8_5, -0.0_1_1_5, -0.0_1_3_2, 0.0_0_1_7, -0.0_9_6_5, -0.0_8_0_2, 0.0_3_9_8,
    0.1_4_3_3, 0.1_7_4_7, -0.0_4_5_8, -0.0_5_3_3, -0.0_4_0_7, 0.1_5_4_5, 0.0_4_1_9, -0.1_5_7_4,
    -0.0_6_4_5, 0.0_6_2_6, 0.0_3_4_1, -0.0_0_1_0, -0.1_1_9_9, -0.1_3_9_0
])
_lowerCamelCase       :				int       =			torch.tensor([
    0.1_0_7_5, 0.1_0_7_4, 0.0_2_0_5, 0.0_4_3_1, -0.0_7_7_4, -0.0_6_0_7, 0.0_2_9_8, 0.2_0_4_2,
    -0.0_3_2_0, 0.1_2_6_7, -0.0_2_8_1, -0.0_2_5_0, -0.0_0_6_4, -0.1_0_9_1, -0.0_9_4_6, 0.0_2_9_0,
    0.1_3_2_8, 0.1_6_5_0, -0.0_5_8_0, -0.0_7_3_8, -0.0_5_8_6, 0.1_4_4_0, 0.0_3_3_7, -0.1_7_4_6,
    -0.0_7_1_2, 0.0_6_0_5, 0.0_2_5_0, -0.0_0_9_9, -0.1_3_1_6, -0.1_4_7_3
])
_lowerCamelCase       :				int       =			torch.tensor([
    -1.4_5_7_2, -2.0_4_8_1, -0.0_4_1_4, -0.6_0_0_5, 1.4_1_3_6, 0.5_8_4_8, 0.4_0_2_8, -2.7_3_3_0,
    1.2_2_1_2, -2.1_2_2_8, 0.2_1_5_5, 0.4_0_3_9, 0.7_6_6_2, 2.0_5_3_5, 0.7_4_7_7, -0.3_2_4_3,
    -2.1_7_5_8, -2.7_6_4_8, 1.6_9_4_7, 0.7_0_2_6, 1.2_3_3_8, -1.6_0_7_8, -0.8_6_8_2, 2.2_8_1_0,
    1.8_5_7_4, -0.5_7_1_8, -0.5_5_8_6, -0.0_1_8_6, 2.3_4_1_5, 2.1_2_5_1])
_lowerCamelCase       :				Tuple       =			torch.tensor([
    -1.3_6_9_0, -1.9_7_2_0, -0.4_0_9_0, -0.6_9_6_6, 1.4_6_6_0, 0.9_9_3_8, -0.1_3_8_5, -2.7_3_2_4,
    0.7_7_3_6, -1.8_9_1_7, 0.2_9_2_3, 0.4_2_9_3, 0.1_6_9_3, 1.4_1_1_2, 1.1_8_8_7, -0.3_1_8_1,
    -2.2_1_6_0, -2.6_3_8_1, 1.3_1_7_0, 0.8_1_6_3, 0.9_2_4_0, -1.6_5_4_4, -0.6_0_9_9, 2.5_2_5_9,
    1.6_4_3_0, -0.9_0_9_0, -0.9_3_9_2, -0.0_1_2_6, 2.4_2_6_8, 2.3_2_6_6
])
_lowerCamelCase       :				List[str]       =			torch.tensor([
    -1.3_5_2_5, -1.9_6_2_8, -0.3_9_5_6, -0.6_8_6_0, 1.4_6_6_4, 1.0_0_1_4, -0.1_2_5_9, -2.7_2_1_2,
    0.7_7_7_2, -1.8_8_1_1, 0.2_9_9_6, 0.4_3_8_8, 0.1_7_0_4, 1.4_0_2_9, 1.1_7_0_1, -0.3_0_2_7,
    -2.2_0_5_3, -2.6_2_8_7, 1.3_3_5_0, 0.8_1_3_1, 0.9_2_7_4, -1.6_2_9_2, -0.6_0_9_8, 2.5_1_3_1,
    1.6_5_0_5, -0.8_9_5_8, -0.9_2_9_8, -0.0_1_5_1, 2.4_2_5_7, 2.3_3_5_5
])
_lowerCamelCase       :				int       =			torch.tensor([
    -2.0_5_8_5, -2.7_8_9_7, -0.2_8_5_0, -0.8_9_4_0, 1.9_0_5_2, 0.5_7_0_2, 0.6_3_4_5, -3.8_9_5_9,
    1.5_9_3_2, -3.2_3_1_9, 0.1_9_7_4, 0.0_2_8_7, 1.7_5_6_6, 2.6_5_4_3, 0.8_3_8_7, -0.5_3_5_1,
    -3.2_7_3_6, -4.3_3_7_5, 2.9_0_2_9, 1.6_3_9_0, 1.4_6_4_0, -2.1_7_0_1, -1.9_0_1_3, 2.9_3_4_1,
    3.4_9_8_1, -0.6_2_5_5, -1.1_6_4_4, -0.1_5_9_1, 3.7_0_9_7, 3.2_0_6_6
])
_lowerCamelCase       :				Tuple       =			torch.tensor([
    -2.3_1_3_9, -2.5_5_9_4, -0.0_1_9_7, -0.6_7_8_5, 1.7_0_0_1, 1.1_6_0_6, 0.3_0_7_5, -2.1_7_4_0,
    1.8_0_7_1, -2.5_6_3_0, -0.0_9_2_6, -0.3_8_1_1, 1.2_1_1_6, 2.6_2_4_6, 1.2_7_3_1, -0.5_3_9_8,
    -2.8_1_5_3, -3.6_1_4_0, 2.3_8_9_3, 1.3_2_6_2, 1.6_2_5_8, -2.1_8_5_6, -1.3_2_6_7, 2.8_3_9_5,
    2.3_7_7_9, -1.0_6_2_3, -1.2_4_6_8, 0.8_9_5_9, 3.3_3_6_7, 3.2_2_4_3
])
_lowerCamelCase       :				int       =			torch.tensor([
    -2.0_6_2_8, -2.7_6_6_7, -0.2_0_8_9, -0.8_2_6_3, 2.0_5_3_9, 0.5_9_9_2, 0.6_4_9_5, -3.8_3_3_6,
    1.6_0_2_5, -3.2_8_1_7, 0.1_7_2_1, -0.0_6_3_3, 1.7_5_1_6, 2.7_0_3_9, 0.8_1_0_0, -0.5_9_0_8,
    -3.2_1_1_3, -4.4_3_4_3, 2.9_2_5_7, 1.3_6_3_2, 1.5_5_6_2, -2.1_4_8_9, -1.9_8_9_4, 3.0_5_6_0,
    3.3_3_9_6, -0.7_3_2_8, -1.0_4_1_7, 0.0_3_8_3, 3.7_0_9_3, 3.2_3_4_3
])
_lowerCamelCase       :				List[Any]       =			torch.tensor([
    -1.4_5_7_4, -2.0_5_6_9, -0.0_4_7_3, -0.6_1_1_7, 1.4_0_1_8, 0.5_7_6_9, 0.4_1_2_9, -2.7_3_4_4,
    1.2_2_4_1, -2.1_3_9_7, 0.2_0_0_0, 0.3_9_3_7, 0.7_6_1_6, 2.0_4_5_3, 0.7_3_2_4, -0.3_3_9_1,
    -2.1_7_4_6, -2.7_7_4_4, 1.6_9_6_3, 0.6_9_2_1, 1.2_1_8_7, -1.6_1_7_2, -0.8_8_7_7, 2.2_4_3_9,
    1.8_4_7_1, -0.5_8_3_9, -0.5_6_0_5, -0.0_4_6_4, 2.3_2_5_0, 2.1_2_1_9
])
# fmt: on

_lowerCamelCase       :				List[str]       =			api.list_models(filter='''diffusers''')
for mod in models:
			if "google" in mod.author or mod.modelId == "CompVis/ldm-celebahq-256":
						_lowerCamelCase       :				Any       =			'''/home/patrick/google_checkpoints/''' + mod.modelId.split('''/''')[-1]

						print(F'Started running {mod.modelId}!!!')

						if mod.modelId.startswith('''CompVis'''):
									_lowerCamelCase       :				Optional[Any]       =			UNetaDModel.from_pretrained(local_checkpoint, subfolder='''unet''')
						else:
									_lowerCamelCase       :				int       =			UNetaDModel.from_pretrained(local_checkpoint)

						torch.manual_seed(0)
						random.seed(0)

						_lowerCamelCase       :				Union[str, Any]       =			torch.randn(1, model.config.in_channels, model.config.sample_size, model.config.sample_size)
						_lowerCamelCase       :				int       =			torch.tensor([10] * noise.shape[0])
						with torch.no_grad():
									_lowerCamelCase       :				int       =			model(noise, time_step).sample

						assert torch.allclose(
						    logits[0, 0, 0, :30], results['''_'''.join('''_'''.join(mod.modelId.split('''/''')).split('''-'''))], atol=1E-3
						)
						print(F'{mod.modelId} has passed successfully!!!')