

import argparse
import collections
import json
import os
import re
import string
import sys

import numpy as np


_UpperCAmelCase	:     Any		       = re.compile(R"""\b(a|an|the)\b""", re.UNICODE)

_UpperCAmelCase	:     Optional[Any]		       = None





def       __lowerCamelCase			(				):







       '''simple docstring'''






       snake_case_           =					argparse.ArgumentParser('Official evaluation script for SQuAD version 2.0.'   )
       parser.add_argument('data_file'     ,							metavar='data.json'     ,							help='Input data JSON file.'   )
       parser.add_argument('pred_file'     ,							metavar='pred.json'     ,							help='Model predictions.'   )
       parser.add_argument(
           '--out-file'     ,							'-o'     ,							metavar='eval.json'     ,							help='Write accuracy metrics to file (default is stdout).'   )
       parser.add_argument(
           '--na-prob-file'     ,							'-n'     ,							metavar='na_prob.json'     ,							help='Model estimates of probability of no answer.'   )
       parser.add_argument(
           '--na-prob-thresh'     ,							'-t'     ,							type=SCREAMING_SNAKE_CASE_     ,							default=1.0     ,							help='Predict \"\" if no-answer probability exceeds this (default = 1.0).'     ,							)
       parser.add_argument(
           '--out-image-dir'     ,							'-p'     ,							metavar='out_images'     ,							default=SCREAMING_SNAKE_CASE_     ,							help='Save precision-recall curves to directory.'   )
       parser.add_argument('--verbose'     ,							'-v'     ,							action='store_true'   )
       if len(sys.argv   ) == 1:
              parser.print_help()
              sys.exit(1   )
       return parser.parse_args()





def       __lowerCamelCase			(				UpperCamelCase__   ):







       '''simple docstring'''






       snake_case_           =					{}
       for article in dataset:
              for p in article["paragraphs"]:
                     for qa in p["qas"]:
                            snake_case_           =					bool(qa['answers']['text']   )
       return qid_to_has_ans





def       __lowerCamelCase			(				UpperCamelCase__   ):







       '''simple docstring'''






       def remove_articles(UpperCamelCase__   ):
              return ARTICLES_REGEX.sub(' '     ,							SCREAMING_SNAKE_CASE_   )

       def white_space_fix(UpperCamelCase__   ):
              return " ".join(text.split()   )

       def remove_punc(UpperCamelCase__   ):
              snake_case_           =					set(string.punctuation   )
              return "".join(ch for ch in text if ch not in exclude   )

       def lower(UpperCamelCase__   ):
              return text.lower()

       return white_space_fix(remove_articles(remove_punc(lower(SCREAMING_SNAKE_CASE_   )   )   )   )





def       __lowerCamelCase			(				UpperCamelCase__   ):







       '''simple docstring'''






       if not s:
              return []
       return normalize_answer(SCREAMING_SNAKE_CASE_   ).split()





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__   ):







       '''simple docstring'''






       return int(normalize_answer(SCREAMING_SNAKE_CASE_   ) == normalize_answer(SCREAMING_SNAKE_CASE_   )   )





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__   ):







       '''simple docstring'''






       snake_case_           =					get_tokens(SCREAMING_SNAKE_CASE_   )
       snake_case_           =					get_tokens(SCREAMING_SNAKE_CASE_   )
       snake_case_           =					collections.Counter(SCREAMING_SNAKE_CASE_   ) & collections.Counter(SCREAMING_SNAKE_CASE_   )
       snake_case_           =					sum(common.values()   )
       if len(SCREAMING_SNAKE_CASE_   ) == 0 or len(SCREAMING_SNAKE_CASE_   ) == 0:
              # If either is no-answer, then F1 is 1 if they agree, 0 otherwise
              return int(gold_toks == pred_toks   )
       if num_same == 0:
              return 0
       snake_case_           =					1.0 * num_same / len(SCREAMING_SNAKE_CASE_   )
       snake_case_           =					1.0 * num_same / len(SCREAMING_SNAKE_CASE_   )
       snake_case_           =					(2 * precision * recall) / (precision + recall)
       return fa





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__   ):







       '''simple docstring'''






       snake_case_           =					{}
       snake_case_           =					{}
       for article in dataset:
              for p in article["paragraphs"]:
                     for qa in p["qas"]:
                            snake_case_           =					qa['id']
                            snake_case_           =					[t for t in qa['answers']['text'] if normalize_answer(SCREAMING_SNAKE_CASE_   )]
                            if not gold_answers:
                                   # For unanswerable questions, only correct answer is empty string
                                   snake_case_           =					['']
                            if qid not in preds:
                                   print(F'''Missing prediction for {qid}'''   )
                                   continue
                            snake_case_           =					preds[qid]
                            # Take max over all gold answers
                            snake_case_           =					max(compute_exact(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_   ) for a in gold_answers   )
                            snake_case_           =					max(compute_fa(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_   ) for a in gold_answers   )
       return exact_scores, fa_scores





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__   ):







       '''simple docstring'''






       snake_case_           =					{}
       for qid, s in scores.items():
              snake_case_           =					na_probs[qid] > na_prob_thresh
              if pred_na:
                     snake_case_           =					float(not qid_to_has_ans[qid]   )
              else:
                     snake_case_           =					s
       return new_scores





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__=None   ):







       '''simple docstring'''






       if not qid_list:
              snake_case_           =					len(SCREAMING_SNAKE_CASE_   )
              return collections.OrderedDict(
                  [
                      ('exact', 1_00.0 * sum(exact_scores.values()   ) / total),
                      ('f1', 1_00.0 * sum(fa_scores.values()   ) / total),
                      ('total', total),
                  ]   )
       else:
              snake_case_           =					len(SCREAMING_SNAKE_CASE_   )
              return collections.OrderedDict(
                  [
                      ('exact', 1_00.0 * sum(exact_scores[k] for k in qid_list   ) / total),
                      ('f1', 1_00.0 * sum(fa_scores[k] for k in qid_list   ) / total),
                      ('total', total),
                  ]   )





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__   ):







       '''simple docstring'''






       for k in new_eval:
              snake_case_           =					new_eval[k]





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__   ):







       '''simple docstring'''






       plt.step(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							color='b'     ,							alpha=0.2     ,							where='post'   )
       plt.fill_between(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							step='post'     ,							alpha=0.2     ,							color='b'   )
       plt.xlabel('Recall'   )
       plt.ylabel('Precision'   )
       plt.xlim([0.0, 1.05]   )
       plt.ylim([0.0, 1.05]   )
       plt.title(SCREAMING_SNAKE_CASE_   )
       plt.savefig(SCREAMING_SNAKE_CASE_   )
       plt.clf()





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__=None     ,							UpperCamelCase__=None   ):







       '''simple docstring'''






       snake_case_           =					sorted(SCREAMING_SNAKE_CASE_     ,							key=lambda UpperCamelCase__   : na_probs[k]   )
       snake_case_           =					0.0
       snake_case_           =					1.0
       snake_case_           =					0.0
       snake_case_           =					[1.0]
       snake_case_           =					[0.0]
       snake_case_           =					0.0
       for i, qid in enumerate(SCREAMING_SNAKE_CASE_   ):
              if qid_to_has_ans[qid]:
                     true_pos += scores[qid]
              snake_case_           =					true_pos / float(i + 1   )
              snake_case_           =					true_pos / float(SCREAMING_SNAKE_CASE_   )
              if i == len(SCREAMING_SNAKE_CASE_   ) - 1 or na_probs[qid] != na_probs[qid_list[i + 1]]:
                     # i.e., if we can put a threshold after this point
                     avg_prec += cur_p * (cur_r - recalls[-1])
                     precisions.append(SCREAMING_SNAKE_CASE_   )
                     recalls.append(SCREAMING_SNAKE_CASE_   )
       if out_image:
              plot_pr_curve(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_   )
       return {"ap": 1_00.0 * avg_prec}





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__   ):







       '''simple docstring'''






       if out_image_dir and not os.path.exists(SCREAMING_SNAKE_CASE_   ):
              os.makedirs(SCREAMING_SNAKE_CASE_   )
       snake_case_           =					sum(1 for v in qid_to_has_ans.values() if v   )
       if num_true_pos == 0:
              return
       snake_case_           =					make_precision_recall_eval(
           SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							out_image=os.path.join(SCREAMING_SNAKE_CASE_     ,							'pr_exact.png'   )     ,							title='Precision-Recall curve for Exact Match score'     ,							)
       snake_case_           =					make_precision_recall_eval(
           SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							out_image=os.path.join(SCREAMING_SNAKE_CASE_     ,							'pr_f1.png'   )     ,							title='Precision-Recall curve for F1 score'     ,							)
       snake_case_           =					{k: float(SCREAMING_SNAKE_CASE_   ) for k, v in qid_to_has_ans.items()}
       snake_case_           =					make_precision_recall_eval(
           SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							out_image=os.path.join(SCREAMING_SNAKE_CASE_     ,							'pr_oracle.png'   )     ,							title='Oracle Precision-Recall curve (binary task of HasAns vs. NoAns)'     ,							)
       merge_eval(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							'pr_exact'   )
       merge_eval(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							'pr_f1'   )
       merge_eval(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							'pr_oracle'   )





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__   ):







       '''simple docstring'''






       if not qid_list:
              return
       snake_case_           =					[na_probs[k] for k in qid_list]
       snake_case_           =					np.ones_like(SCREAMING_SNAKE_CASE_   ) / float(len(SCREAMING_SNAKE_CASE_   )   )
       plt.hist(SCREAMING_SNAKE_CASE_     ,							weights=SCREAMING_SNAKE_CASE_     ,							bins=20     ,							range=(0.0, 1.0)   )
       plt.xlabel('Model probability of no-answer'   )
       plt.ylabel('Proportion of dataset'   )
       plt.title(F'''Histogram of no-answer probability: {name}'''   )
       plt.savefig(os.path.join(SCREAMING_SNAKE_CASE_     ,							F'''na_prob_hist_{name}.png'''   )   )
       plt.clf()





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__   ):







       '''simple docstring'''






       snake_case_           =					sum(1 for k in qid_to_has_ans if not qid_to_has_ans[k]   )
       snake_case_           =					num_no_ans
       snake_case_           =					cur_score
       snake_case_           =					0.0
       snake_case_           =					sorted(SCREAMING_SNAKE_CASE_     ,							key=lambda UpperCamelCase__   : na_probs[k]   )
       for i, qid in enumerate(SCREAMING_SNAKE_CASE_   ):
              if qid not in scores:
                     continue
              if qid_to_has_ans[qid]:
                     snake_case_           =					scores[qid]
              else:
                     if preds[qid]:
                            snake_case_           =					-1
                     else:
                            snake_case_           =					0
              cur_score += diff
              if cur_score > best_score:
                     snake_case_           =					cur_score
                     snake_case_           =					na_probs[qid]
       return 1_00.0 * best_score / len(SCREAMING_SNAKE_CASE_   ), best_thresh





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__   ):







       '''simple docstring'''






       snake_case_       ,					snake_case_           =					find_best_thresh(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_   )
       snake_case_       ,					snake_case_           =					find_best_thresh(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_   )
       snake_case_           =					best_exact
       snake_case_           =					exact_thresh
       snake_case_           =					best_fa
       snake_case_           =					fa_thresh





def       __lowerCamelCase			(				):







       '''simple docstring'''






       with open(OPTS.data_file   ) as f:
              snake_case_           =					json.load(SCREAMING_SNAKE_CASE_   )
              snake_case_           =					dataset_json['data']
       with open(OPTS.pred_file   ) as f:
              snake_case_           =					json.load(SCREAMING_SNAKE_CASE_   )
       if OPTS.na_prob_file:
              with open(OPTS.na_prob_file   ) as f:
                     snake_case_           =					json.load(SCREAMING_SNAKE_CASE_   )
       else:
              snake_case_           =					{k: 0.0 for k in preds}
       snake_case_           =					make_qid_to_has_ans(SCREAMING_SNAKE_CASE_   )  # maps qid to True/False
       snake_case_           =					[k for k, v in qid_to_has_ans.items() if v]
       snake_case_           =					[k for k, v in qid_to_has_ans.items() if not v]
       snake_case_       ,					snake_case_           =					get_raw_scores(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_   )
       snake_case_           =					apply_no_ans_threshold(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							OPTS.na_prob_thresh   )
       snake_case_           =					apply_no_ans_threshold(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							OPTS.na_prob_thresh   )
       snake_case_           =					make_eval_dict(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_   )
       if has_ans_qids:
              snake_case_           =					make_eval_dict(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							qid_list=SCREAMING_SNAKE_CASE_   )
              merge_eval(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							'HasAns'   )
       if no_ans_qids:
              snake_case_           =					make_eval_dict(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							qid_list=SCREAMING_SNAKE_CASE_   )
              merge_eval(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							'NoAns'   )
       if OPTS.na_prob_file:
              find_all_best_thresh(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_   )
       if OPTS.na_prob_file and OPTS.out_image_dir:
              run_precision_recall_analysis(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							OPTS.out_image_dir   )
              histogram_na_prob(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							OPTS.out_image_dir     ,							'hasAns'   )
              histogram_na_prob(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_     ,							OPTS.out_image_dir     ,							'noAns'   )
       if OPTS.out_file:
              with open(OPTS.out_file     ,							'w'   ) as f:
                     json.dump(SCREAMING_SNAKE_CASE_     ,							SCREAMING_SNAKE_CASE_   )
       else:
              print(json.dumps(SCREAMING_SNAKE_CASE_     ,							indent=2   )   )


if __name__ == "__main__":
     _UpperCAmelCase	:     Optional[int]		       = parse_args()
     if OPTS.out_image_dir:
          import matplotlib

          matplotlib.use("""Agg""")
          import matplotlib.pyplot as plt
     main()







import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from ...utils import logging
from ..auto import CONFIG_MAPPING


_UpperCAmelCase	:     Dict		       = logging.get_logger(__name__)

_UpperCAmelCase	:     Dict		       = {
    """salesforce/blip2-opt-2.7b""": """https://huggingface.co/salesforce/blip2-opt-2.7b/resolve/main/config.json""",
}







class 				lowercase       ( lowercase_    ):
				__SCREAMING_SNAKE_CASE      :				Optional[int]     =    '''blip_2_vision_model'''




				def __init__(      self   ,     snake_case=1408   ,     snake_case=6144   ,     snake_case=39   ,     snake_case=16   ,     snake_case=224   ,     snake_case=14   ,     snake_case="gelu"   ,     snake_case=0.0_00_01   ,     snake_case=0.0   ,     snake_case=1e-1_0   ,     snake_case=True   ,     **snake_case   ,     ):
											super().__init__(**snake_case )

											snake_case_           =					hidden_size
											snake_case_           =					intermediate_size
											snake_case_           =					num_hidden_layers
											snake_case_           =					num_attention_heads
											snake_case_           =					patch_size
											snake_case_           =					image_size
											snake_case_           =					initializer_range
											snake_case_           =					attention_dropout
											snake_case_           =					layer_norm_eps
											snake_case_           =					hidden_act
											snake_case_           =					qkv_bias




				@classmethod
				def 					a							(      cls   ,     snake_case   ,     **snake_case ):
											cls._set_token_in_kwargs(snake_case )

											snake_case_       ,					snake_case_           =					cls.get_config_dict(snake_case   ,     **snake_case )

											# get the vision config dict if we are loading from Blip2Config
											if config_dict.get('model_type' ) == "blip-2":
																		snake_case_           =					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(snake_case   ,     **snake_case )







class 				lowercase       ( lowercase_    ):
				__SCREAMING_SNAKE_CASE      :				Any     =    '''blip_2_qformer'''




				def __init__(      self   ,     snake_case=3_0522   ,     snake_case=768   ,     snake_case=12   ,     snake_case=12   ,     snake_case=3072   ,     snake_case="gelu"   ,     snake_case=0.1   ,     snake_case=0.1   ,     snake_case=512   ,     snake_case=0.02   ,     snake_case=1e-1_2   ,     snake_case=0   ,     snake_case="absolute"   ,     snake_case=2   ,     snake_case=1408   ,     **snake_case   ,     ):
											super().__init__(pad_token_id=snake_case   ,     **snake_case )

											snake_case_           =					vocab_size
											snake_case_           =					hidden_size
											snake_case_           =					num_hidden_layers
											snake_case_           =					num_attention_heads
											snake_case_           =					hidden_act
											snake_case_           =					intermediate_size
											snake_case_           =					hidden_dropout_prob
											snake_case_           =					attention_probs_dropout_prob
											snake_case_           =					max_position_embeddings
											snake_case_           =					initializer_range
											snake_case_           =					layer_norm_eps
											snake_case_           =					position_embedding_type
											snake_case_           =					cross_attention_frequency
											snake_case_           =					encoder_hidden_size




				@classmethod
				def 					a							(      cls   ,     snake_case   ,     **snake_case ):
											cls._set_token_in_kwargs(snake_case )

											snake_case_       ,					snake_case_           =					cls.get_config_dict(snake_case   ,     **snake_case )

											# get the qformer config dict if we are loading from Blip2Config
											if config_dict.get('model_type' ) == "blip-2":
																		snake_case_           =					config_dict['qformer_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(snake_case   ,     **snake_case )







class 				lowercase       ( lowercase_    ):
				__SCREAMING_SNAKE_CASE      :				Optional[int]     =    '''blip-2'''
				__SCREAMING_SNAKE_CASE      :				Dict     =    True




				def __init__(      self   ,     snake_case=None   ,     snake_case=None   ,     snake_case=None   ,     snake_case=32   ,     **snake_case ):
											super().__init__(**snake_case )

											if vision_config is None:
																		snake_case_           =					{}
																		logger.info('vision_config is None. initializing the Blip2VisionConfig with default values.' )

											if qformer_config is None:
																		snake_case_           =					{}
																		logger.info('qformer_config is None. Initializing the Blip2QFormerConfig with default values.' )

											if text_config is None:
																		snake_case_           =					{}
																		logger.info('text_config is None. Initializing the text config with default values (`OPTConfig`).' )

											snake_case_           =					BlipaVisionConfig(**snake_case )
											snake_case_           =					BlipaQFormerConfig(**snake_case )
											snake_case_           =					text_config['model_type'] if 'model_type' in text_config else 'opt'
											snake_case_           =					CONFIG_MAPPING[text_model_type](**snake_case )

											snake_case_           =					self.text_config.tie_word_embeddings
											snake_case_           =					self.text_config.is_encoder_decoder

											snake_case_           =					num_query_tokens
											snake_case_           =					self.vision_config.hidden_size
											snake_case_           =					self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
											snake_case_           =					1.0
											snake_case_           =					0.02




				@classmethod
				def 					a							(      cls   ,     snake_case   ,     snake_case   ,     snake_case   ,     **snake_case   ,     ):
											return cls(
											    vision_config=vision_config.to_dict()   ,     qformer_config=qformer_config.to_dict()   ,     text_config=text_config.to_dict()   ,     **snake_case   ,     )




				def 					a							(      self ):
											snake_case_           =					copy.deepcopy(self.__dict__ )
											snake_case_           =					self.vision_config.to_dict()
											snake_case_           =					self.qformer_config.to_dict()
											snake_case_           =					self.text_config.to_dict()
											snake_case_           =					self.__class__.model_type
											return output




