



"""simple docstring"""





from . import (
    albert,
    align,
    altclip,
    audio_spectrogram_transformer,
    auto,
    autoformer,
    bark,
    bart,
    barthez,
    bartpho,
    beit,
    bert,
    bert_generation,
    bert_japanese,
    bertweet,
    big_bird,
    bigbird_pegasus,
    biogpt,
    bit,
    blenderbot,
    blenderbot_small,
    blip,
    blip_a,
    bloom,
    bridgetower,
    byta,
    camembert,
    canine,
    chinese_clip,
    clap,
    clip,
    clipseg,
    codegen,
    conditional_detr,
    convbert,
    convnext,
    convnextva,
    cpm,
    cpmant,
    ctrl,
    cvt,
    dataavec,
    deberta,
    deberta_va,
    decision_transformer,
    deformable_detr,
    deit,
    deprecated,
    deta,
    detr,
    dialogpt,
    dinat,
    distilbert,
    dit,
    donut,
    dpr,
    dpt,
    efficientformer,
    efficientnet,
    electra,
    encodec,
    encoder_decoder,
    ernie,
    ernie_m,
    esm,
    falcon,
    flaubert,
    flava,
    fnet,
    focalnet,
    fsmt,
    funnel,
    git,
    glpn,
    gpta,
    gpt_bigcode,
    gpt_neo,
    gpt_neox,
    gpt_neox_japanese,
    gpt_swa,
    gptj,
    gptsan_japanese,
    graphormer,
    groupvit,
    herbert,
    hubert,
    ibert,
    imagegpt,
    informer,
    instructblip,
    jukebox,
    layoutlm,
    layoutlmva,
    layoutlmva,
    layoutxlm,
    led,
    levit,
    lilt,
    llama,
    longformer,
    longta,
    luke,
    lxmert,
    mam_aaa,
    marian,
    markuplm,
    maskaformer,
    maskformer,
    mbart,
    mbartaa,
    mega,
    megatron_bert,
    megatron_gpta,
    mgp_str,
    mluke,
    mobilebert,
    mobilenet_va,
    mobilenet_va,
    mobilevit,
    mobilevitva,
    mpnet,
    mra,
    mta,
    musicgen,
    mvp,
    nat,
    nezha,
    nllb,
    nllb_moe,
    nystromformer,
    oneformer,
    open_llama,
    openai,
    opt,
    owlvit,
    pegasus,
    pegasus_x,
    perceiver,
    phobert,
    pixastruct,
    plbart,
    poolformer,
    prophetnet,
    qdqbert,
    rag,
    realm,
    reformer,
    regnet,
    rembert,
    resnet,
    roberta,
    roberta_prelayernorm,
    roc_bert,
    roformer,
    rwkv,
    sam,
    segformer,
    sew,
    sew_d,
    speech_encoder_decoder,
    speech_to_text,
    speech_to_text_a,
    speechta,
    splinter,
    squeezebert,
    swiftformer,
    swin,
    swinasr,
    swinva,
    switch_transformers,
    ta,
    table_transformer,
    tapas,
    time_series_transformer,
    timesformer,
    timm_backbone,
    transfo_xl,
    trocr,
    tvlt,
    umta,
    unispeech,
    unispeech_sat,
    upernet,
    videomae,
    vilt,
    vision_encoder_decoder,
    vision_text_dual_encoder,
    visual_bert,
    vit,
    vit_hybrid,
    vit_mae,
    vit_msn,
    vivit,
    wavaveca,
    wavaveca_conformer,
    wavaveca_phoneme,
    wavaveca_with_lm,
    wavlm,
    whisper,
    x_clip,
    xglm,
    xlm,
    xlm_prophetnet,
    xlm_roberta,
    xlm_roberta_xl,
    xlnet,
    xmod,
    yolos,
    yoso,
)







"""simple docstring"""





import unittest

import numpy as np

from transformers.testing_utils import require_flax, require_tf, require_torch
from transformers.utils import (
    expand_dims,
    flatten_dict,
    is_flax_available,
    is_tf_available,
    is_torch_available,
    reshape,
    squeeze,
    transpose,
)


if is_flax_available():
					import jax.numpy as jnp

if is_tf_available():
					import tensorflow as tf

if is_torch_available():
					import torch




class 			lowercase__			(      unittest.TestCase    ):
							'''simple docstring'''







							def        lowerCamelCase_   (  self						)			->							Dict:
									_UpperCAmelCase							 =		{
									    'task_specific_params': {
									        'summarization': {'length_penalty': 1.0, 'max_length': 128, 'min_length': 12, 'num_beams': 4},
									        'summarization_cnn': {'length_penalty': 2.0, 'max_length': 142, 'min_length': 56, 'num_beams': 4},
									        'summarization_xsum': {'length_penalty': 1.0, 'max_length': 62, 'min_length': 11, 'num_beams': 6},
									    }
									}
									_UpperCAmelCase							 =		{
									    'task_specific_params.summarization.length_penalty': 1.0,
									    'task_specific_params.summarization.max_length': 128,
									    'task_specific_params.summarization.min_length': 12,
									    'task_specific_params.summarization.num_beams': 4,
									    'task_specific_params.summarization_cnn.length_penalty': 2.0,
									    'task_specific_params.summarization_cnn.max_length': 142,
									    'task_specific_params.summarization_cnn.min_length': 56,
									    'task_specific_params.summarization_cnn.num_beams': 4,
									    'task_specific_params.summarization_xsum.length_penalty': 1.0,
									    'task_specific_params.summarization_xsum.max_length': 62,
									    'task_specific_params.summarization_xsum.min_length': 11,
									    'task_specific_params.summarization_xsum.num_beams': 6,
									}

									self.assertEqual(flatten_dict(snake_case						)	,       snake_case						)






							def        lowerCamelCase_   (  self						)			->							List[str]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									self.assertTrue(np.allclose(transpose(snake_case						)	,       x.transpose()						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									self.assertTrue(np.allclose(transpose(snake_case	,       axes=(1, 2, 0)						)	,       x.transpose((1, 2, 0)						)						)						)






							@require_torch
							def        lowerCamelCase_   (  self						)			->							List[str]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case						)	,       transpose(snake_case						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case	,       axes=(1, 2, 0)						)	,       transpose(snake_case	,       axes=(1, 2, 0)						).numpy()						)						)






							@require_tf
							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case						)	,       transpose(snake_case						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case	,       axes=(1, 2, 0)						)	,       transpose(snake_case	,       axes=(1, 2, 0)						).numpy()						)						)






							@require_flax
							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case						)	,       np.asarray(transpose(snake_case						)						)						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case	,       axes=(1, 2, 0)						)	,       np.asarray(transpose(snake_case	,       axes=(1, 2, 0)						)						)						)						)






							def        lowerCamelCase_   (  self						)			->							List[str]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (4, 3)						)	,       np.reshape(snake_case	,       (4, 3)						)						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (12, 5)						)	,       np.reshape(snake_case	,       (12, 5)						)						)						)






							@require_torch
							def        lowerCamelCase_   (  self						)			->							Optional[Any]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (4, 3)						)	,       reshape(snake_case	,       (4, 3)						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (12, 5)						)	,       reshape(snake_case	,       (12, 5)						).numpy()						)						)






							@require_tf
							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (4, 3)						)	,       reshape(snake_case	,       (4, 3)						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (12, 5)						)	,       reshape(snake_case	,       (12, 5)						).numpy()						)						)






							@require_flax
							def        lowerCamelCase_   (  self						)			->							Tuple:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (4, 3)						)	,       np.asarray(reshape(snake_case	,       (4, 3)						)						)						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (12, 5)						)	,       np.asarray(reshape(snake_case	,       (12, 5)						)						)						)						)






							def        lowerCamelCase_   (  self						)			->							str:
									_UpperCAmelCase							 =		np.random.randn(1	,       3	,       4						)
									self.assertTrue(np.allclose(squeeze(snake_case						)	,       np.squeeze(snake_case						)						)						)

									_UpperCAmelCase							 =		np.random.randn(1	,       4	,       1	,       5						)
									self.assertTrue(np.allclose(squeeze(snake_case	,       axis=2						)	,       np.squeeze(snake_case	,       axis=2						)						)						)






							@require_torch
							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		np.random.randn(1	,       3	,       4						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case						)	,       squeeze(snake_case						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(1	,       4	,       1	,       5						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case	,       axis=2						)	,       squeeze(snake_case	,       axis=2						).numpy()						)						)






							@require_tf
							def        lowerCamelCase_   (  self						)			->							Optional[int]:
									_UpperCAmelCase							 =		np.random.randn(1	,       3	,       4						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case						)	,       squeeze(snake_case						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(1	,       4	,       1	,       5						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case	,       axis=2						)	,       squeeze(snake_case	,       axis=2						).numpy()						)						)






							@require_flax
							def        lowerCamelCase_   (  self						)			->							str:
									_UpperCAmelCase							 =		np.random.randn(1	,       3	,       4						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case						)	,       np.asarray(squeeze(snake_case						)						)						)						)

									_UpperCAmelCase							 =		np.random.randn(1	,       4	,       1	,       5						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case	,       axis=2						)	,       np.asarray(squeeze(snake_case	,       axis=2						)						)						)						)






							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									self.assertTrue(np.allclose(expand_dims(snake_case	,       axis=1						)	,       np.expand_dims(snake_case	,       axis=1						)						)						)






							@require_torch
							def        lowerCamelCase_   (  self						)			->							Dict:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(expand_dims(snake_case	,       axis=1						)	,       expand_dims(snake_case	,       axis=1						).numpy()						)						)






							@require_tf
							def        lowerCamelCase_   (  self						)			->							int:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(expand_dims(snake_case	,       axis=1						)	,       expand_dims(snake_case	,       axis=1						).numpy()						)						)






							@require_flax
							def        lowerCamelCase_   (  self						)			->							str:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(expand_dims(snake_case	,       axis=1						)	,       np.asarray(expand_dims(snake_case	,       axis=1						)						)						)						)


