

from typing import Optional, Tuple, Union

import flax
import flax.linen as nn
import jax
import jax.numpy as jnp
from flax.core.frozen_dict import FrozenDict

from ..configuration_utils import ConfigMixin, flax_register_to_config
from ..utils import BaseOutput
from .embeddings_flax import FlaxTimestepEmbedding, FlaxTimesteps
from .modeling_flax_utils import FlaxModelMixin
from .unet_ad_blocks_flax import (
    FlaxCrossAttnDownBlockaD,
    FlaxDownBlockaD,
    FlaxUNetMidBlockaDCrossAttn,
)

@flax.struct.dataclass
class 					a__						(					snake_case			):
			"""simple docstring"""







			__lowerCamelCase        =       42
			__lowerCamelCase        =       42

class 					a__						(					nn.Module			):
			"""simple docstring"""







			__lowerCamelCase        =       42
			__lowerCamelCase        =       (16, 32, 96, 256)
			__lowerCamelCase        =       jnp.floataa


			def      UpperCamelCase		(    self       )  ->						str:
										'''simple docstring'''






										A__        =			nn.Conv(
										    self.block_out_channels[0]      ,      kernel_size=(3, 3)      ,      padding=((1, 1), (1, 1))      ,      dtype=self.dtype      ,      )

										A__        =			[]
										for i in range(len(self.block_out_channels       ) - 1       ):
																	A__        =			self.block_out_channels[i]
																	A__        =			self.block_out_channels[i + 1]
																	A__        =			nn.Conv(
																	    UpperCAmelCase__      ,      kernel_size=(3, 3)      ,      padding=((1, 1), (1, 1))      ,      dtype=self.dtype      ,      )
																	blocks.append(UpperCAmelCase__       )
																	A__        =			nn.Conv(
																	    UpperCAmelCase__      ,      kernel_size=(3, 3)      ,      strides=(2, 2)      ,      padding=((1, 1), (1, 1))      ,      dtype=self.dtype      ,      )
																	blocks.append(UpperCAmelCase__       )
										A__        =			blocks

										A__        =			nn.Conv(
										    self.conditioning_embedding_channels      ,      kernel_size=(3, 3)      ,      padding=((1, 1), (1, 1))      ,      kernel_init=nn.initializers.zeros_init()      ,      bias_init=nn.initializers.zeros_init()      ,      dtype=self.dtype      ,      )


			def __call__(    self      ,      lowercase       )  ->						Dict:
										'''simple docstring'''






										A__        =			self.conv_in(UpperCAmelCase__       )
										A__        =			nn.silu(UpperCAmelCase__       )

										for block in self.blocks:
																	A__        =			block(UpperCAmelCase__       )
																	A__        =			nn.silu(UpperCAmelCase__       )

										A__        =			self.conv_out(UpperCAmelCase__       )

										return embedding

@flax_register_to_config
class 					a__						(					nn.Module							,	snake_case							,	snake_case			):
			"""simple docstring"""







			__lowerCamelCase        =       32
			__lowerCamelCase        =       4
			__lowerCamelCase        =       (
			    "CrossAttnDownBlock2D",
			    "CrossAttnDownBlock2D",
			    "CrossAttnDownBlock2D",
			    "DownBlock2D",
			)
			__lowerCamelCase        =       False
			__lowerCamelCase        =       (320, 640, 1280, 1280)
			__lowerCamelCase        =       2
			__lowerCamelCase        =       8
			__lowerCamelCase        =       None
			__lowerCamelCase        =       1280
			__lowerCamelCase        =       0.0
			__lowerCamelCase        =       False
			__lowerCamelCase        =       jnp.floataa
			__lowerCamelCase        =       True
			__lowerCamelCase        =       0
			__lowerCamelCase        =       "rgb"
			__lowerCamelCase        =       (16, 32, 96, 256)


			def      UpperCamelCase		(    self      ,      lowercase       )  ->						str:
										'''simple docstring'''






										A__        =			(1, self.in_channels, self.sample_size, self.sample_size)
										A__        =			jnp.zeros(UpperCAmelCase__      ,      dtype=jnp.floataa       )
										A__        =			jnp.ones((1,)      ,      dtype=jnp.intaa       )
										A__        =			jnp.zeros((1, 1, self.cross_attention_dim)      ,      dtype=jnp.floataa       )
										A__        =			(1, 3, self.sample_size * 8, self.sample_size * 8)
										A__        =			jnp.zeros(UpperCAmelCase__      ,      dtype=jnp.floataa       )

										A__        =			jax.random.split(UpperCAmelCase__       )
										A__        =			{'''params''': params_rng, '''dropout''': dropout_rng}

										return self.init(UpperCAmelCase__      ,      UpperCAmelCase__      ,      UpperCAmelCase__      ,      UpperCAmelCase__      ,      UpperCAmelCase__       )["params"]


			def      UpperCamelCase		(    self       )  ->						int:
										'''simple docstring'''






										A__        =			self.block_out_channels
										A__        =			block_out_channels[0] * 4

										# If `num_attention_heads` is not defined (which is the case for most models)
										# it will default to `attention_head_dim`. This looks weird upon first reading it and it is.
										# The reason for this behavior is to correct for incorrectly named variables that were introduced
										# when this library was created. The incorrect naming was only discovered much later in https://github.com/huggingface/diffusers/issues/2011#issuecomment-1547958131
										# Changing `attention_head_dim` to `num_attention_heads` for 40,000+ configurations is too backwards breaking
										# which is why we correct for the naming here.
										A__        =			self.num_attention_heads or self.attention_head_dim

										# input
										A__        =			nn.Conv(
										    block_out_channels[0]      ,      kernel_size=(3, 3)      ,      strides=(1, 1)      ,      padding=((1, 1), (1, 1))      ,      dtype=self.dtype      ,      )

										# time
										A__        =			FlaxTimesteps(
										    block_out_channels[0]      ,      flip_sin_to_cos=self.flip_sin_to_cos      ,      freq_shift=self.config.freq_shift       )
										A__        =			FlaxTimestepEmbedding(UpperCAmelCase__      ,      dtype=self.dtype       )

										A__        =			FlaxControlNetConditioningEmbedding(
										    conditioning_embedding_channels=block_out_channels[0]      ,      block_out_channels=self.conditioning_embedding_out_channels      ,      )

										A__        =			self.only_cross_attention
										if isinstance(UpperCAmelCase__      ,      UpperCAmelCase__       ):
																	A__        =			(only_cross_attention,) * len(self.down_block_types       )

										if isinstance(UpperCAmelCase__      ,      UpperCAmelCase__       ):
																	A__        =			(num_attention_heads,) * len(self.down_block_types       )

										# down
										A__        =			[]
										A__        =			[]

										A__        =			block_out_channels[0]

										A__        =			nn.Conv(
										    UpperCAmelCase__      ,      kernel_size=(1, 1)      ,      padding="VALID"      ,      kernel_init=nn.initializers.zeros_init()      ,      bias_init=nn.initializers.zeros_init()      ,      dtype=self.dtype      ,      )
										controlnet_down_blocks.append(UpperCAmelCase__       )

										for i, down_block_type in enumerate(self.down_block_types       ):
																	A__        =			output_channel
																	A__        =			block_out_channels[i]
																	A__        =			i == len(UpperCAmelCase__       ) - 1

																	if down_block_type == "CrossAttnDownBlock2D":
																								A__        =			FlaxCrossAttnDownBlockaD(
																								    in_channels=UpperCAmelCase__      ,      out_channels=UpperCAmelCase__      ,      dropout=self.dropout      ,      num_layers=self.layers_per_block      ,      num_attention_heads=num_attention_heads[i]      ,      add_downsample=not is_final_block      ,      use_linear_projection=self.use_linear_projection      ,      only_cross_attention=only_cross_attention[i]      ,      dtype=self.dtype      ,      )
																	else:
																								A__        =			FlaxDownBlockaD(
																								    in_channels=UpperCAmelCase__      ,      out_channels=UpperCAmelCase__      ,      dropout=self.dropout      ,      num_layers=self.layers_per_block      ,      add_downsample=not is_final_block      ,      dtype=self.dtype      ,      )

																	down_blocks.append(UpperCAmelCase__       )

																	for _ in range(self.layers_per_block       ):
																								A__        =			nn.Conv(
																								    UpperCAmelCase__      ,      kernel_size=(1, 1)      ,      padding="VALID"      ,      kernel_init=nn.initializers.zeros_init()      ,      bias_init=nn.initializers.zeros_init()      ,      dtype=self.dtype      ,      )
																								controlnet_down_blocks.append(UpperCAmelCase__       )

																	if not is_final_block:
																								A__        =			nn.Conv(
																								    UpperCAmelCase__      ,      kernel_size=(1, 1)      ,      padding="VALID"      ,      kernel_init=nn.initializers.zeros_init()      ,      bias_init=nn.initializers.zeros_init()      ,      dtype=self.dtype      ,      )
																								controlnet_down_blocks.append(UpperCAmelCase__       )

										A__        =			down_blocks
										A__        =			controlnet_down_blocks

										# mid
										A__        =			block_out_channels[-1]
										A__        =			FlaxUNetMidBlockaDCrossAttn(
										    in_channels=UpperCAmelCase__      ,      dropout=self.dropout      ,      num_attention_heads=num_attention_heads[-1]      ,      use_linear_projection=self.use_linear_projection      ,      dtype=self.dtype      ,      )

										A__        =			nn.Conv(
										    UpperCAmelCase__      ,      kernel_size=(1, 1)      ,      padding="VALID"      ,      kernel_init=nn.initializers.zeros_init()      ,      bias_init=nn.initializers.zeros_init()      ,      dtype=self.dtype      ,      )


			def __call__(    self      ,      lowercase      ,      lowercase      ,      lowercase      ,      lowercase      ,      lowercase = 1.0      ,      lowercase = True      ,      lowercase = False      ,      )  ->						Tuple:
										'''simple docstring'''






										A__        =			self.controlnet_conditioning_channel_order
										if channel_order == "bgr":
																	A__        =			jnp.flip(UpperCAmelCase__      ,      axis=1       )

										# 1. time
										if not isinstance(UpperCAmelCase__      ,      jnp.ndarray       ):
																	A__        =			jnp.array([timesteps]      ,      dtype=jnp.intaa       )
										elif isinstance(UpperCAmelCase__      ,      jnp.ndarray       ) and len(timesteps.shape       ) == 0:
																	A__        =			timesteps.astype(dtype=jnp.floataa       )
																	A__        =			jnp.expand_dims(UpperCAmelCase__      ,      0       )

										A__        =			self.time_proj(UpperCAmelCase__       )
										A__        =			self.time_embedding(UpperCAmelCase__       )

										# 2. pre-process
										A__        =			jnp.transpose(UpperCAmelCase__      ,      (0, 2, 3, 1)       )
										A__        =			self.conv_in(UpperCAmelCase__       )

										A__        =			jnp.transpose(UpperCAmelCase__      ,      (0, 2, 3, 1)       )
										A__        =			self.controlnet_cond_embedding(UpperCAmelCase__       )
										sample += controlnet_cond

										# 3. down
										A__        =			(sample,)
										for down_block in self.down_blocks:
																	if isinstance(UpperCAmelCase__      ,      UpperCAmelCase__       ):
																								A__        =			down_block(UpperCAmelCase__      ,      UpperCAmelCase__      ,      UpperCAmelCase__      ,      deterministic=not train       )
																	else:
																								A__        =			down_block(UpperCAmelCase__      ,      UpperCAmelCase__      ,      deterministic=not train       )
																	down_block_res_samples += res_samples

										# 4. mid
										A__        =			self.mid_block(UpperCAmelCase__      ,      UpperCAmelCase__      ,      UpperCAmelCase__      ,      deterministic=not train       )

										# 5. contronet blocks
										A__        =			()
										for down_block_res_sample, controlnet_block in zip(UpperCAmelCase__      ,      self.controlnet_down_blocks       ):
																	A__        =			controlnet_block(UpperCAmelCase__       )
																	controlnet_down_block_res_samples += (down_block_res_sample,)

										A__        =			controlnet_down_block_res_samples

										A__        =			self.controlnet_mid_block(UpperCAmelCase__       )

										# 6. scaling
										A__        =			[sample * conditioning_scale for sample in down_block_res_samples]
										mid_block_res_sample *= conditioning_scale

										if not return_dict:
																	return (down_block_res_samples, mid_block_res_sample)

										return FlaxControlNetOutput(
										    down_block_res_samples=UpperCAmelCase__      ,      mid_block_res_sample=UpperCAmelCase__       )




from __future__ import annotations

import copy
import tempfile
import unittest

from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available
from transformers.testing_utils import (
    DUMMY_UNKNOWN_IDENTIFIER,
    SMALL_MODEL_IDENTIFIER,
    RequestCounter,
    require_tensorflow_probability,
    require_tf,
    slow,
)

from ..bert.test_modeling_bert import BertModelTester


if is_tf_available():
	from transformers import (
	    TFAutoModel,
	    TFAutoModelForCausalLM,
	    TFAutoModelForMaskedLM,
	    TFAutoModelForPreTraining,
	    TFAutoModelForQuestionAnswering,
	    TFAutoModelForSeqaSeqLM,
	    TFAutoModelForSequenceClassification,
	    TFAutoModelForTableQuestionAnswering,
	    TFAutoModelForTokenClassification,
	    TFAutoModelWithLMHead,
	    TFBertForMaskedLM,
	    TFBertForPreTraining,
	    TFBertForQuestionAnswering,
	    TFBertForSequenceClassification,
	    TFBertModel,
	    TFFunnelBaseModel,
	    TFFunnelModel,
	    TFGPTaLMHeadModel,
	    TFRobertaForMaskedLM,
	    TFTaForConditionalGeneration,
	    TFTapasForQuestionAnswering,
	)
	from transformers.models.auto.modeling_tf_auto import (
	    TF_MODEL_FOR_CAUSAL_LM_MAPPING,
	    TF_MODEL_FOR_MASKED_LM_MAPPING,
	    TF_MODEL_FOR_PRETRAINING_MAPPING,
	    TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
	    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
	    TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
	    TF_MODEL_MAPPING,
	)
	from transformers.models.bert.modeling_tf_bert import TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST
	from transformers.models.gpta.modeling_tf_gpta import TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST
	from transformers.models.ta.modeling_tf_ta import TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST
	from transformers.models.tapas.modeling_tf_tapas import TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST

class 					a__						(					snake_case			):
			"""simple docstring"""







			__lowerCamelCase        =       'new-model'


if is_tf_available():

	class 					a__						(					snake_case			):
				"""simple docstring"""







				__lowerCamelCase        =       NewModelConfig

@require_tf
class 					a__						(					unittest.TestCase			):
			"""simple docstring"""







			@slow
			def      UpperCamelCase		(    self       )  ->						List[Any]:
							'''simple docstring'''






							A__        =			"bert-base-cased"
							A__        =			AutoConfig.from_pretrained(lowercase       )
							self.assertIsNotNone(lowercase       )
							self.assertIsInstance(lowercase      ,      lowercase       )

							A__        =			TFAutoModel.from_pretrained(lowercase       )
							self.assertIsNotNone(lowercase       )
							self.assertIsInstance(lowercase      ,      lowercase       )


			@slow
			def      UpperCamelCase		(    self       )  ->						Optional[Any]:
							'''simple docstring'''






							A__        =			"bert-base-cased"
							A__        =			AutoConfig.from_pretrained(lowercase       )
							self.assertIsNotNone(lowercase       )
							self.assertIsInstance(lowercase      ,      lowercase       )

							A__        =			TFAutoModelForPreTraining.from_pretrained(lowercase       )
							self.assertIsNotNone(lowercase       )
							self.assertIsInstance(lowercase      ,      lowercase       )


			@slow
			def      UpperCamelCase		(    self       )  ->						Dict:
							'''simple docstring'''






							for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											A__        =			AutoConfig.from_pretrained(lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )

											A__        =			TFAutoModelForCausalLM.from_pretrained(lowercase       )
											A__    ,				A__        =			TFAutoModelForCausalLM.from_pretrained(lowercase      ,      output_loading_info=lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )


			@slow
			def      UpperCamelCase		(    self       )  ->						Optional[int]:
							'''simple docstring'''






							for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											A__        =			AutoConfig.from_pretrained(lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )

											A__        =			TFAutoModelWithLMHead.from_pretrained(lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )


			@slow
			def      UpperCamelCase		(    self       )  ->						int:
							'''simple docstring'''






							for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											A__        =			AutoConfig.from_pretrained(lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )

											A__        =			TFAutoModelForMaskedLM.from_pretrained(lowercase       )
											A__    ,				A__        =			TFAutoModelForMaskedLM.from_pretrained(lowercase      ,      output_loading_info=lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )


			@slow
			def      UpperCamelCase		(    self       )  ->						str:
							'''simple docstring'''






							for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											A__        =			AutoConfig.from_pretrained(lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )

											A__        =			TFAutoModelForSeqaSeqLM.from_pretrained(lowercase       )
											A__    ,				A__        =			TFAutoModelForSeqaSeqLM.from_pretrained(lowercase      ,      output_loading_info=lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )


			@slow
			def      UpperCamelCase		(    self       )  ->						Dict:
							'''simple docstring'''






							for model_name in ["bert-base-uncased"]:
											A__        =			AutoConfig.from_pretrained(lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )

											A__        =			TFAutoModelForSequenceClassification.from_pretrained(lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )


			@slow
			def      UpperCamelCase		(    self       )  ->						int:
							'''simple docstring'''






							for model_name in ["bert-base-uncased"]:
											A__        =			AutoConfig.from_pretrained(lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )

											A__        =			TFAutoModelForQuestionAnswering.from_pretrained(lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )


			@slow
			@require_tensorflow_probability
			def      UpperCamelCase		(    self       )  ->						List[str]:
							'''simple docstring'''






							for model_name in TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST[5:6]:
											A__        =			AutoConfig.from_pretrained(lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )

											A__        =			TFAutoModelForTableQuestionAnswering.from_pretrained(lowercase       )
											A__    ,				A__        =			TFAutoModelForTableQuestionAnswering.from_pretrained(
											    lowercase      ,      output_loading_info=lowercase       )
											self.assertIsNotNone(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )


			def      UpperCamelCase		(    self       )  ->						Dict:
							'''simple docstring'''






							A__        =			TFAutoModelWithLMHead.from_pretrained(lowercase       )
							self.assertIsInstance(lowercase      ,      lowercase       )
							self.assertEqual(model.num_parameters()      ,      14410       )
							self.assertEqual(model.num_parameters(only_trainable=lowercase       )      ,      14410       )


			def      UpperCamelCase		(    self       )  ->						Any:
							'''simple docstring'''






							A__        =			TFAutoModelWithLMHead.from_pretrained(lowercase       )
							self.assertIsInstance(lowercase      ,      lowercase       )
							self.assertEqual(model.num_parameters()      ,      14410       )
							self.assertEqual(model.num_parameters(only_trainable=lowercase       )      ,      14410       )


			def      UpperCamelCase		(    self       )  ->						int:
							'''simple docstring'''






							A__        =			TFAutoModel.from_pretrained("sgugger/funnel-random-tiny"       )
							self.assertIsInstance(lowercase      ,      lowercase       )

							A__        =			copy.deepcopy(model.config       )
							A__        =			["FunnelBaseModel"]
							A__        =			TFAutoModel.from_config(lowercase       )
							self.assertIsInstance(lowercase      ,      lowercase       )

							with tempfile.TemporaryDirectory() as tmp_dir:
											model.save_pretrained(lowercase       )
											A__        =			TFAutoModel.from_pretrained(lowercase       )
											self.assertIsInstance(lowercase      ,      lowercase       )


			def      UpperCamelCase		(    self       )  ->						Optional[Any]:
							'''simple docstring'''






							try:
											AutoConfig.register("new-model"      ,      lowercase       )

											A__        =			[
											    TFAutoModel,
											    TFAutoModelForCausalLM,
											    TFAutoModelForMaskedLM,
											    TFAutoModelForPreTraining,
											    TFAutoModelForQuestionAnswering,
											    TFAutoModelForSequenceClassification,
											    TFAutoModelForTokenClassification,
											]

											for auto_class in auto_classes:
															with self.subTest(auto_class.__name__       ):
																			# Wrong config class will raise an error
																			with self.assertRaises(lowercase       ):
																							auto_class.register(lowercase      ,      lowercase       )
																			auto_class.register(lowercase      ,      lowercase       )
																			# Trying to register something existing in the Transformers library will raise an error
																			with self.assertRaises(lowercase       ):
																							auto_class.register(lowercase      ,      lowercase       )

																			# Now that the config is registered, it can be used as any other config with the auto-API
																			A__        =			BertModelTester(self       ).get_config()
																			A__        =			NewModelConfig(**tiny_config.to_dict()       )
																			A__        =			auto_class.from_config(lowercase       )
																			self.assertIsInstance(lowercase      ,      lowercase       )

																			with tempfile.TemporaryDirectory() as tmp_dir:
																							model.save_pretrained(lowercase       )
																							A__        =			auto_class.from_pretrained(lowercase       )
																							self.assertIsInstance(lowercase      ,      lowercase       )

							finally:
											if "new-model" in CONFIG_MAPPING._extra_content:
															del CONFIG_MAPPING._extra_content["new-model"]
											for mapping in (
											    TF_MODEL_MAPPING,
											    TF_MODEL_FOR_PRETRAINING_MAPPING,
											    TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
											    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
											    TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
											    TF_MODEL_FOR_CAUSAL_LM_MAPPING,
											    TF_MODEL_FOR_MASKED_LM_MAPPING,
											):
															if NewModelConfig in mapping._extra_content:
																			del mapping._extra_content[NewModelConfig]


			def      UpperCamelCase		(    self       )  ->						str:
							'''simple docstring'''






							with self.assertRaisesRegex(
							    lowercase      ,      "bert-base is not a local folder and is not a valid model identifier"       ):
											A__        =			TFAutoModel.from_pretrained("bert-base"       )


			def      UpperCamelCase		(    self       )  ->						Optional[Any]:
							'''simple docstring'''






							with self.assertRaisesRegex(
							    lowercase      ,      R"aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)"       ):
											A__        =			TFAutoModel.from_pretrained(lowercase      ,      revision="aaaaaa"       )


			def      UpperCamelCase		(    self       )  ->						Union[str, Any]:
							'''simple docstring'''






							with self.assertRaisesRegex(
							    lowercase      ,      "hf-internal-testing/config-no-model does not appear to have a file named pytorch_model.bin"      ,      ):
											A__        =			TFAutoModel.from_pretrained("hf-internal-testing/config-no-model"       )


			def      UpperCamelCase		(    self       )  ->						Union[str, Any]:
							'''simple docstring'''






							with self.assertRaisesRegex(lowercase      ,      "Use `from_pt=True` to load this model"       ):
											A__        =			TFAutoModel.from_pretrained("hf-internal-testing/tiny-bert-pt-only"       )


			def      UpperCamelCase		(    self       )  ->						Any:
							'''simple docstring'''






							A__        =			TFAutoModel.from_pretrained("hf-internal-testing/tiny-random-bert"       )
							with RequestCounter() as counter:
											A__        =			TFAutoModel.from_pretrained("hf-internal-testing/tiny-random-bert"       )
											self.assertEqual(counter.get_request_count      ,      0       )
											self.assertEqual(counter.head_request_count      ,      1       )
											self.assertEqual(counter.other_request_count      ,      0       )

							# With a sharded checkpoint
							A__        =			TFAutoModel.from_pretrained("ArthurZ/tiny-random-bert-sharded"       )
							with RequestCounter() as counter:
											A__        =			TFAutoModel.from_pretrained("ArthurZ/tiny-random-bert-sharded"       )
											self.assertEqual(counter.get_request_count      ,      0       )
											self.assertEqual(counter.head_request_count      ,      1       )
											self.assertEqual(counter.other_request_count      ,      0       )

