



from __future__ import annotations

import unittest

from transformers import LEDConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
     import tensorflow as tf

     from transformers import TFLEDForConditionalGeneration, TFLEDModel






@require_tf
class SCREAMING_SNAKE_CASE__					:




    '''simple docstring'''






    __lowerCamelCase      :			Any =				LEDConfig
    __lowerCamelCase      :			Optional[Any] =				{}
    __lowerCamelCase      :			Any =				"gelu"






    def __init__(	self,		lowerCamelCase__,		lowerCamelCase__=13,		lowerCamelCase__=7,		lowerCamelCase__=True,		lowerCamelCase__=False,		lowerCamelCase__=99,		lowerCamelCase__=32,		lowerCamelCase__=2,		lowerCamelCase__=4,		lowerCamelCase__=37,		lowerCamelCase__=0.1,		lowerCamelCase__=0.1,		lowerCamelCase__=20,		lowerCamelCase__=2,		lowerCamelCase__=1,		lowerCamelCase__=0,		lowerCamelCase__=4,		):
        A			:	Union[str, Any]										=       parent
        A			:	List[str]										=       batch_size
        A			:	List[str]										=       seq_length
        A			:	List[str]										=       is_training
        A			:	int										=       use_labels
        A			:	Dict										=       vocab_size
        A			:	Optional[int]										=       hidden_size
        A			:	Dict										=       num_hidden_layers
        A			:	Any										=       num_attention_heads
        A			:	Tuple										=       intermediate_size

        A			:	Optional[int]										=       hidden_dropout_prob
        A			:	int										=       attention_probs_dropout_prob
        A			:	Optional[Any]										=       max_position_embeddings
        A			:	Tuple										=       eos_token_id
        A			:	Dict										=       pad_token_id
        A			:	str										=       bos_token_id
        A			:	Any										=       attention_window

        # `ModelTesterMixin.test_attention_outputs` is expecting attention tensors to be of size
        # [num_attention_heads, encoder_seq_length, encoder_key_length], but TFLongformerSelfAttention
        # returns attention of shape [num_attention_heads, encoder_seq_length, self.attention_window + 1]
        # because its local attention only attends to `self.attention_window` and one before and one after
        A			:	Any										=       self.attention_window + 2

        # because of padding `encoder_seq_length`, is different from `seq_length`. Relevant for
        # the `test_attention_outputs` and `test_hidden_states_output` tests
        A			:	Union[str, Any]										=       (
            self.seq_length + (self.attention_window - self.seq_length % self.attention_window) % self.attention_window
        )






    def       _lowerCAmelCase (	self		):
        A			:	int										=       ids_tensor([self.batch_size, self.seq_length - 1],		self.vocab_size		)
        A			:	Any										=       tf.expand_dims(tf.constant([self.eos_token_id] * self.batch_size		),		1		)
        A			:	Any										=       tf.concat([input_ids, eos_tensor],		axis=1		)

        A			:	str										=       ids_tensor([self.batch_size, self.seq_length],		self.vocab_size		)

        A			:	Any										=       self.config_cls(
            vocab_size=self.vocab_size,		d_model=self.hidden_size,		encoder_layers=self.num_hidden_layers,		decoder_layers=self.num_hidden_layers,		encoder_attention_heads=self.num_attention_heads,		decoder_attention_heads=self.num_attention_heads,		encoder_ffn_dim=self.intermediate_size,		decoder_ffn_dim=self.intermediate_size,		dropout=self.hidden_dropout_prob,		attention_dropout=self.attention_probs_dropout_prob,		max_position_embeddings=self.max_position_embeddings,		eos_token_ids=[2],		bos_token_id=self.bos_token_id,		pad_token_id=self.pad_token_id,		decoder_start_token_id=self.pad_token_id,		attention_window=self.attention_window,		**self.config_updates,		)
        A			:	int										=       prepare_led_inputs_dict(lowerCamelCase__,		lowerCamelCase__,		lowerCamelCase__		)
        A			:	int										=       tf.concat(
            [tf.zeros_like(lowerCamelCase__		)[:, :-1], tf.ones_like(lowerCamelCase__		)[:, -1:]],		axis=-1,		)
        A			:	str										=       global_attention_mask
        return config, inputs_dict






    def       _lowerCAmelCase (	self,		lowerCamelCase__,		lowerCamelCase__		):
        A			:	Union[str, Any]										=       TFLEDModel(config=lowerCamelCase__		).get_decoder()
        A			:	Any										=       inputs_dict["""input_ids"""]

        A			:	List[str]										=       input_ids[:1, :]
        A			:	Union[str, Any]										=       inputs_dict["""attention_mask"""][:1, :]
        A			:	Any										=       1

        # first forward pass
        A			:	List[str]										=       model(lowerCamelCase__,		attention_mask=lowerCamelCase__,		use_cache=lowerCamelCase__		)

        A					,							A			:	str										=       outputs.to_tuple()

        # create hypothetical next token and extent to next_input_ids
        A			:	List[Any]										=       ids_tensor((self.batch_size, 3),		config.vocab_size		)
        A			:	List[str]										=       tf.cast(ids_tensor((self.batch_size, 3),		2		),		tf.inta		)

        # append to next input_ids and
        A			:	Union[str, Any]										=       tf.concat([input_ids, next_tokens],		axis=-1		)
        A			:	str										=       tf.concat([attention_mask, next_attn_mask],		axis=-1		)

        A			:	List[str]										=       model(lowerCamelCase__,		attention_mask=lowerCamelCase__		)[0]
        A			:	List[Any]										=       model(lowerCamelCase__,		attention_mask=lowerCamelCase__,		past_key_values=lowerCamelCase__		)[0]

        self.parent.assertEqual(next_tokens.shape[1],		output_from_past.shape[1]		)

        # select random slice
        A			:	Union[str, Any]										=       int(ids_tensor((1,),		output_from_past.shape[-1]		)		)
        A			:	Union[str, Any]										=       output_from_no_past[:, -3:, random_slice_idx]
        A			:	Dict										=       output_from_past[:, :, random_slice_idx]

        # test that outputs are equal for slice
        tf.debugging.assert_near(lowerCamelCase__,		lowerCamelCase__,		rtol=1e-3		)




def      __UpperCamelCase     (  _lowerCAmelCase				,					_lowerCAmelCase				,					_lowerCAmelCase				,					_lowerCAmelCase=None				,					_lowerCAmelCase=None				,					_lowerCAmelCase=None				,					_lowerCAmelCase=None				,					)	->  str:



    """simple docstring"""






    if attention_mask is None:
        A			:	Tuple										=       tf.cast(tf.math.not_equal(_lowerCAmelCase				,					config.pad_token_id		)				,					tf.inta		)
    if decoder_attention_mask is None:
        A			:	Optional[int]										=       tf.concat(
            [
                tf.ones(decoder_input_ids[:, :1].shape				,					dtype=tf.inta		),
                tf.cast(tf.math.not_equal(decoder_input_ids[:, 1:]				,					config.pad_token_id		)				,					tf.inta		),
            ]				,					axis=-1				,					)
    if head_mask is None:
        A			:	Dict										=       tf.ones((config.encoder_layers, config.encoder_attention_heads)		)
    if decoder_head_mask is None:
        A			:	Dict										=       tf.ones((config.decoder_layers, config.decoder_attention_heads)		)
    return {
        "input_ids": input_ids,
        "attention_mask": attention_mask,
        "decoder_input_ids": decoder_input_ids,
        "decoder_attention_mask": decoder_attention_mask,
        "head_mask": head_mask,
        "decoder_head_mask": decoder_head_mask,
    }






@require_tf
class SCREAMING_SNAKE_CASE__					(		SCREAMING_SNAKE_CASE__			,						SCREAMING_SNAKE_CASE__			,						unittest.TestCase   ):




    '''simple docstring'''






    __lowerCamelCase      :			Any =				(TFLEDForConditionalGeneration, TFLEDModel) if is_tf_available() else ()
    __lowerCamelCase      :			Dict =				(TFLEDForConditionalGeneration,) if is_tf_available() else ()
    __lowerCamelCase      :			Dict =				(
        {
            "conversational": TFLEDForConditionalGeneration,
            "feature-extraction": TFLEDModel,
            "summarization": TFLEDForConditionalGeneration,
            "text2text-generation": TFLEDForConditionalGeneration,
            "translation": TFLEDForConditionalGeneration,
        }
        if is_tf_available()
        else {}
    )
    __lowerCamelCase      :			List[str] =				True
    __lowerCamelCase      :			Dict =				False
    __lowerCamelCase      :			str =				False
    __lowerCamelCase      :			Union[str, Any] =				False






    def       _lowerCAmelCase (	self		):
        A			:	List[Any]										=       TFLEDModelTester(self		)
        A			:	Tuple										=       ConfigTester(self,		config_class=lowerCamelCase__		)






    def       _lowerCAmelCase (	self		):
        self.config_tester.run_common_tests()






    def       _lowerCAmelCase (	self		):
        A			:	Tuple										=       self.model_tester.prepare_config_and_inputs_for_common()
        self.model_tester.check_decoder_model_past_large_inputs(*lowerCamelCase__		)






    def       _lowerCAmelCase (	self		):
        A					,							A			:	Union[str, Any]										=       self.model_tester.prepare_config_and_inputs_for_common()
        A			:	str										=       tf.zeros_like(inputs_dict["""attention_mask"""]		)
        A			:	Any										=       2
        A			:	Optional[int]										=       tf.where(
            tf.range(self.model_tester.seq_length		)[None, :] < num_global_attn_indices,		1,		inputs_dict["""global_attention_mask"""],		)

        A			:	Tuple										=       True
        A			:	int										=       self.model_tester.seq_length
        A			:	Any										=       self.model_tester.encoder_seq_length

        def check_decoder_attentions_output(lowerCamelCase__		):
            A			:	int										=       outputs.decoder_attentions
            self.assertEqual(len(lowerCamelCase__		),		self.model_tester.num_hidden_layers		)
            self.assertListEqual(
                list(decoder_attentions[0].shape[-3:]		),		[self.model_tester.num_attention_heads, seq_length, seq_length],		)

        def check_encoder_attentions_output(lowerCamelCase__		):
            A			:	str										=       [t.numpy() for t in outputs.encoder_attentions]
            A			:	Optional[int]										=       [t.numpy() for t in outputs.encoder_global_attentions]
            self.assertEqual(len(lowerCamelCase__		),		self.model_tester.num_hidden_layers		)
            self.assertEqual(len(lowerCamelCase__		),		self.model_tester.num_hidden_layers		)
            self.assertListEqual(
                list(attentions[0].shape[-3:]		),		[self.model_tester.num_attention_heads, seq_length, seq_length],		)
            self.assertListEqual(
                list(global_attentions[0].shape[-3:]		),		[self.model_tester.num_attention_heads, encoder_seq_length, num_global_attn_indices],		)

        for model_class in self.all_model_classes:
            A			:	Union[str, Any]										=       True
            A			:	Optional[int]										=       False
            A			:	Tuple										=       False
            A			:	str										=       model_class(lowerCamelCase__		)
            A			:	Optional[Any]										=       model(self._prepare_for_class(lowerCamelCase__,		lowerCamelCase__		)		)
            A			:	Optional[int]										=       len(lowerCamelCase__		)
            self.assertEqual(config.output_hidden_states,		lowerCamelCase__		)
            check_encoder_attentions_output(lowerCamelCase__		)

            if self.is_encoder_decoder:
                A			:	Tuple										=       model_class(lowerCamelCase__		)
                A			:	Any										=       model(self._prepare_for_class(lowerCamelCase__,		lowerCamelCase__		)		)
                self.assertEqual(config.output_hidden_states,		lowerCamelCase__		)
                check_decoder_attentions_output(lowerCamelCase__		)

            # Check that output attentions can also be changed via the config
            del inputs_dict["output_attentions"]
            A			:	Dict										=       True
            A			:	str										=       model_class(lowerCamelCase__		)
            A			:	Tuple										=       model(self._prepare_for_class(lowerCamelCase__,		lowerCamelCase__		)		)
            self.assertEqual(config.output_hidden_states,		lowerCamelCase__		)
            check_encoder_attentions_output(lowerCamelCase__		)

            # Check attention is always last and order is fine
            A			:	Tuple										=       True
            A			:	Dict										=       True
            A			:	List[str]										=       model_class(lowerCamelCase__		)
            A			:	Tuple										=       model(self._prepare_for_class(lowerCamelCase__,		lowerCamelCase__		)		)

            self.assertEqual(out_len + (2 if self.is_encoder_decoder else 1),		len(lowerCamelCase__		)		)
            self.assertEqual(model.config.output_hidden_states,		lowerCamelCase__		)
            check_encoder_attentions_output(lowerCamelCase__		)






    @unittest.skip("""LED keeps using potentially symbolic tensors in conditionals and breaks tracing."""		)
    def       _lowerCAmelCase (	self		):
        pass






    def       _lowerCAmelCase (	self		):
        # TODO: Head-masking not yet implement
        pass




def      __UpperCamelCase     (  _lowerCAmelCase		)	->  Optional[Any]:



    """simple docstring"""






    return tf.constant(_lowerCAmelCase				,					dtype=tf.intaa		)


SCREAMING_SNAKE_CASE_:List[str]					=						1E-4






@slow
@require_tf
class SCREAMING_SNAKE_CASE__					(		unittest.TestCase   ):




    '''simple docstring'''






    def       _lowerCAmelCase (	self		):
        A			:	Optional[int]										=       TFLEDForConditionalGeneration.from_pretrained("""allenai/led-base-16384"""		).led

        # change to intended input here
        A			:	Any										=       _long_tensor([512 * [0, 3_1414, 232, 328, 740, 1140, 1_2695, 69]]		)
        A			:	Union[str, Any]										=       _long_tensor([128 * [0, 3_1414, 232, 328, 740, 1140, 1_2695, 69]]		)
        A			:	Tuple										=       prepare_led_inputs_dict(model.config,		lowerCamelCase__,		lowerCamelCase__		)
        A			:	Optional[Any]										=       model(**lowerCamelCase__		)[0]
        A			:	Union[str, Any]										=       (1, 1024, 768)
        self.assertEqual(output.shape,		lowerCamelCase__		)
        # change to expected output here
        A			:	str										=       tf.convert_to_tensor(
            [[2.3050, 2.8279, 0.6531], [-1.8457, -0.1455, -3.5661], [-1.0186, 0.4586, -2.2043]],		)
        tf.debugging.assert_near(output[:, :3, :3],		lowerCamelCase__,		atol=1e-3		)






    def       _lowerCAmelCase (	self		):
        A			:	Union[str, Any]										=       TFLEDForConditionalGeneration.from_pretrained("""allenai/led-base-16384"""		)

        # change to intended input here
        A			:	Dict										=       _long_tensor([512 * [0, 3_1414, 232, 328, 740, 1140, 1_2695, 69]]		)
        A			:	Dict										=       _long_tensor([128 * [0, 3_1414, 232, 328, 740, 1140, 1_2695, 69]]		)
        A			:	Optional[Any]										=       prepare_led_inputs_dict(model.config,		lowerCamelCase__,		lowerCamelCase__		)
        A			:	Dict										=       model(**lowerCamelCase__		)[0]
        A			:	List[Any]										=       (1, 1024, model.config.vocab_size)
        self.assertEqual(output.shape,		lowerCamelCase__		)
        # change to expected output here
        A			:	Dict										=       tf.convert_to_tensor(
            [[33.6507, 6.4572, 16.8089], [5.8739, -2.4238, 11.2902], [-3.2139, -4.3149, 4.2783]],		)
        tf.debugging.assert_near(output[:, :3, :3],		lowerCamelCase__,		atol=1e-3,		rtol=1e-3		)







import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


SCREAMING_SNAKE_CASE_:Optional[int]					=						logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_:Dict					=						{
    """BAAI/AltCLIP""": """https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json""",
    # See all AltCLIP models at https://huggingface.co/models?filter=altclip
}






class SCREAMING_SNAKE_CASE__					(		SCREAMING_SNAKE_CASE__   ):




    '''simple docstring'''






    __lowerCamelCase      :			int =				"altclip_text_model"






    def __init__(	self,		lowerCamelCase__=25_0002,		lowerCamelCase__=1024,		lowerCamelCase__=24,		lowerCamelCase__=16,		lowerCamelCase__=4096,		lowerCamelCase__="gelu",		lowerCamelCase__=0.1,		lowerCamelCase__=0.1,		lowerCamelCase__=514,		lowerCamelCase__=1,		lowerCamelCase__=0.02,		lowerCamelCase__=0.02,		lowerCamelCase__=1e-05,		lowerCamelCase__=1,		lowerCamelCase__=0,		lowerCamelCase__=2,		lowerCamelCase__="absolute",		lowerCamelCase__=True,		lowerCamelCase__=768,		**lowerCamelCase__,		):
        super().__init__(pad_token_id=lowerCamelCase__,		bos_token_id=lowerCamelCase__,		eos_token_id=lowerCamelCase__,		**lowerCamelCase__		)

        A			:	Union[str, Any]										=       vocab_size
        A			:	Dict										=       hidden_size
        A			:	Union[str, Any]										=       num_hidden_layers
        A			:	List[str]										=       num_attention_heads
        A			:	str										=       hidden_act
        A			:	Dict										=       intermediate_size
        A			:	List[str]										=       hidden_dropout_prob
        A			:	Optional[Any]										=       attention_probs_dropout_prob
        A			:	Tuple										=       max_position_embeddings
        A			:	Optional[Any]										=       type_vocab_size
        A			:	Optional[Any]										=       initializer_range
        A			:	Optional[int]										=       initializer_factor
        A			:	Tuple										=       layer_norm_eps
        A			:	List[str]										=       position_embedding_type
        A			:	int										=       use_cache
        A			:	int										=       project_dim






class SCREAMING_SNAKE_CASE__					(		SCREAMING_SNAKE_CASE__   ):




    '''simple docstring'''






    __lowerCamelCase      :			Optional[Any] =				"altclip_vision_model"






    def __init__(	self,		lowerCamelCase__=768,		lowerCamelCase__=3072,		lowerCamelCase__=512,		lowerCamelCase__=12,		lowerCamelCase__=12,		lowerCamelCase__=3,		lowerCamelCase__=224,		lowerCamelCase__=32,		lowerCamelCase__="quick_gelu",		lowerCamelCase__=1e-5,		lowerCamelCase__=0.0,		lowerCamelCase__=0.02,		lowerCamelCase__=1.0,		**lowerCamelCase__,		):
        super().__init__(**lowerCamelCase__		)

        A			:	Optional[Any]										=       hidden_size
        A			:	Optional[int]										=       intermediate_size
        A			:	Union[str, Any]										=       projection_dim
        A			:	str										=       num_hidden_layers
        A			:	int										=       num_attention_heads
        A			:	Optional[Any]										=       num_channels
        A			:	Tuple										=       patch_size
        A			:	List[Any]										=       image_size
        A			:	Optional[int]										=       initializer_range
        A			:	Union[str, Any]										=       initializer_factor
        A			:	List[str]										=       attention_dropout
        A			:	int										=       layer_norm_eps
        A			:	str										=       hidden_act






    @classmethod
    def       _lowerCAmelCase (	cls,		lowerCamelCase__,		**lowerCamelCase__		):
        cls._set_token_in_kwargs(lowerCamelCase__		)

        A					,							A			:	Optional[Any]										=       cls.get_config_dict(lowerCamelCase__,		**lowerCamelCase__		)

        # get the vision config dict if we are loading from AltCLIPConfig
        if config_dict.get("""model_type"""		) == "altclip":
            A			:	Any										=       config_dict["""vision_config"""]

        if "model_type" in config_dict and hasattr(cls,		"""model_type"""		) and config_dict["model_type"] != cls.model_type:
            logger.warning(
                f'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
                f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''		)

        return cls.from_dict(lowerCamelCase__,		**lowerCamelCase__		)






class SCREAMING_SNAKE_CASE__					(		SCREAMING_SNAKE_CASE__   ):




    '''simple docstring'''






    __lowerCamelCase      :			List[Any] =				"altclip"
    __lowerCamelCase      :			List[Any] =				True






    def __init__(	self,		lowerCamelCase__=None,		lowerCamelCase__=None,		lowerCamelCase__=768,		lowerCamelCase__=2.6592,		**lowerCamelCase__		):
        # If `_config_dict` exist, we use them for the backward compatibility.
        # We pop out these 2 attributes before calling `super().__init__` to avoid them being saved (which causes a lot
        # of confusion!).
        A			:	Dict										=       kwargs.pop("""text_config_dict""",		lowerCamelCase__		)
        A			:	str										=       kwargs.pop("""vision_config_dict""",		lowerCamelCase__		)

        super().__init__(**lowerCamelCase__		)

        # Instead of simply assigning `[text|vision]_config_dict` to `[text|vision]_config`, we use the values in
        # `[text|vision]_config_dict` to update the values in `[text|vision]_config`. The values should be same in most
        # cases, but we don't want to break anything regarding `_config_dict` that existed before commit `8827e1b2`.
        if text_config_dict is not None:
            if text_config is None:
                A			:	Dict										=       {}

            # This is the complete result when using `text_config_dict`.
            A			:	str										=       AltCLIPTextConfig(**lowerCamelCase__		).to_dict()

            # Give a warning if the values exist in both `_text_config_dict` and `text_config` but being different.
            for key, value in _text_config_dict.items():
                if key in text_config and value != text_config[key] and key not in ["transformers_version"]:
                    # If specified in `text_config_dict`
                    if key in text_config_dict:
                        A			:	Optional[Any]										=       (
                            f'''`{key}` is found in both `text_config_dict` and `text_config` but with different values. '''
                            f'''The value `text_config_dict["{key}"]` will be used instead.'''
                        )
                    # If inferred from default argument values (just to be super careful)
                    else:
                        A			:	Optional[int]										=       (
                            f'''`text_config_dict` is provided which will be used to initialize `AltCLIPTextConfig`. The '''
                            f'''value `text_config["{key}"]` will be overriden.'''
                        )
                    logger.warning(lowerCamelCase__		)

            # Update all values in `text_config` with the ones in `_text_config_dict`.
            text_config.update(_text_config_dict		)

        if vision_config_dict is not None:
            if vision_config is None:
                A			:	int										=       {}

            # This is the complete result when using `vision_config_dict`.
            A			:	Union[str, Any]										=       AltCLIPVisionConfig(**lowerCamelCase__		).to_dict()
            # convert keys to string instead of integer
            if "id2label" in _vision_config_dict:
                A			:	Optional[int]										=       {
                    str(lowerCamelCase__		): value for key, value in _vision_config_dict["""id2label"""].items()
                }

            # Give a warning if the values exist in both `_vision_config_dict` and `vision_config` but being different.
            for key, value in _vision_config_dict.items():
                if key in vision_config and value != vision_config[key] and key not in ["transformers_version"]:
                    # If specified in `vision_config_dict`
                    if key in vision_config_dict:
                        A			:	Optional[int]										=       (
                            f'''`{key}` is found in both `vision_config_dict` and `vision_config` but with different '''
                            f'''values. The value `vision_config_dict["{key}"]` will be used instead.'''
                        )
                    # If inferred from default argument values (just to be super careful)
                    else:
                        A			:	Any										=       (
                            f'''`vision_config_dict` is provided which will be used to initialize `AltCLIPVisionConfig`. '''
                            f'''The value `vision_config["{key}"]` will be overriden.'''
                        )
                    logger.warning(lowerCamelCase__		)

            # Update all values in `vision_config` with the ones in `_vision_config_dict`.
            vision_config.update(_vision_config_dict		)

        if text_config is None:
            A			:	Tuple										=       {}
            logger.info("""`text_config` is `None`. Initializing the `AltCLIPTextConfig` with default values."""		)

        if vision_config is None:
            A			:	Union[str, Any]										=       {}
            logger.info("""`vision_config` is `None`. initializing the `AltCLIPVisionConfig` with default values."""		)

        A			:	Dict										=       AltCLIPTextConfig(**lowerCamelCase__		)
        A			:	Optional[int]										=       AltCLIPVisionConfig(**lowerCamelCase__		)

        A			:	List[str]										=       projection_dim
        A			:	Any										=       logit_scale_init_value
        A			:	Tuple										=       1.0






    @classmethod
    def       _lowerCAmelCase (	cls,		lowerCamelCase__,		lowerCamelCase__,		**lowerCamelCase__		):
        return cls(text_config=text_config.to_dict(),		vision_config=vision_config.to_dict(),		**lowerCamelCase__		)






    def       _lowerCAmelCase (	self		):
        A			:	str										=       copy.deepcopy(self.__dict__		)
        A			:	Any										=       self.text_config.to_dict()
        A			:	List[str]										=       self.vision_config.to_dict()
        A			:	Union[str, Any]										=       self.__class__.model_type
        return output


