


import json
import os
from functools import lru_cache
from typing import List, Optional, Tuple

import regex as re

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


lowercase_           =	logging.get_logger(__name__)

lowercase_           =	{
    'vocab_file': 'vocab.json',
    'merges_file': 'merges.txt',
}

lowercase_           =	{
    'vocab_file': {
        'roberta-base': 'https://huggingface.co/roberta-base/resolve/main/vocab.json',
        'roberta-large': 'https://huggingface.co/roberta-large/resolve/main/vocab.json',
        'roberta-large-mnli': 'https://huggingface.co/roberta-large-mnli/resolve/main/vocab.json',
        'distilroberta-base': 'https://huggingface.co/distilroberta-base/resolve/main/vocab.json',
        'roberta-base-openai-detector': 'https://huggingface.co/roberta-base-openai-detector/resolve/main/vocab.json',
        'roberta-large-openai-detector': (
            'https://huggingface.co/roberta-large-openai-detector/resolve/main/vocab.json'
        ),
    },
    'merges_file': {
        'roberta-base': 'https://huggingface.co/roberta-base/resolve/main/merges.txt',
        'roberta-large': 'https://huggingface.co/roberta-large/resolve/main/merges.txt',
        'roberta-large-mnli': 'https://huggingface.co/roberta-large-mnli/resolve/main/merges.txt',
        'distilroberta-base': 'https://huggingface.co/distilroberta-base/resolve/main/merges.txt',
        'roberta-base-openai-detector': 'https://huggingface.co/roberta-base-openai-detector/resolve/main/merges.txt',
        'roberta-large-openai-detector': (
            'https://huggingface.co/roberta-large-openai-detector/resolve/main/merges.txt'
        ),
    },
}

lowercase_           =	{
    'roberta-base': 5_1_2,
    'roberta-large': 5_1_2,
    'roberta-large-mnli': 5_1_2,
    'distilroberta-base': 5_1_2,
    'roberta-base-openai-detector': 5_1_2,
    'roberta-large-openai-detector': 5_1_2,
}
@lru_cache()
def       UpperCamelCase__     (  ):
 __lowerCamelCase		:							Optional[Any]							=						(
     list(range(ord('!'						)			,       ord('~'						) + 1						)						) + list(range(ord('¡'						)			,       ord('¬'						) + 1						)						) + list(range(ord('®'						)			,       ord('ÿ'						) + 1						)						)
 )
 __lowerCamelCase		:							Any							=						bs[:]
 __lowerCamelCase		:							List[str]							=						0
 for b in range(2**8						):
  if b not in bs:
   bs.append(SCREAMING_SNAKE_CASE__						)
   cs.append(2**8 + n						)
   n += 1
 __lowerCamelCase		:							int							=						[chr(SCREAMING_SNAKE_CASE__						) for n in cs]
 return dict(zip(SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__						)						)
def       UpperCamelCase__     (  SCREAMING_SNAKE_CASE__						):
 __lowerCamelCase		:							Dict							=						set()
 __lowerCamelCase		:							str							=						word[0]
 for char in word[1:]:
  pairs.add((prev_char, char)						)
  __lowerCamelCase		:							Optional[int]							=						char
 return pairs



class        A_					(       __UpperCamelCase    ):




      '''simple docstring'''


      __snake_case					       =   VOCAB_FILES_NAMES
      __snake_case					       =   PRETRAINED_VOCAB_FILES_MAP
      __snake_case					       =   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
      __snake_case					       =   ["""input_ids""", """attention_mask"""]




      def __init__(				self:       Optional[int]						,      a:       str						,      a:       Union[str, Any]						,      a:       Optional[int]="replace"						,      a:       Dict="<s>"						,      a:       int="</s>"						,      a:       Tuple="</s>"						,      a:       Dict="<s>"						,      a:       Optional[Any]="<unk>"						,      a:       Dict="<pad>"						,      a:       Optional[int]="<mask>"						,      a:       Optional[int]=False						,      **a:       int						,      ):
       __lowerCamelCase		:							List[Any]							=						AddedToken(a						,      lstrip=a						,      rstrip=a				) if isinstance(a						,      a				) else bos_token
       __lowerCamelCase		:							str							=						AddedToken(a						,      lstrip=a						,      rstrip=a				) if isinstance(a						,      a				) else eos_token
       __lowerCamelCase		:							Optional[int]							=						AddedToken(a						,      lstrip=a						,      rstrip=a				) if isinstance(a						,      a				) else sep_token
       __lowerCamelCase		:							Any							=						AddedToken(a						,      lstrip=a						,      rstrip=a				) if isinstance(a						,      a				) else cls_token
       __lowerCamelCase		:							Dict							=						AddedToken(a						,      lstrip=a						,      rstrip=a				) if isinstance(a						,      a				) else unk_token
       __lowerCamelCase		:							Optional[Any]							=						AddedToken(a						,      lstrip=a						,      rstrip=a				) if isinstance(a						,      a				) else pad_token

       # Mask token behave like a normal word, i.e. include the space before it
       __lowerCamelCase		:							Dict							=						AddedToken(a						,      lstrip=a						,      rstrip=a				) if isinstance(a						,      a				) else mask_token

       super().__init__(
           errors=a						,      bos_token=a						,      eos_token=a						,      unk_token=a						,      sep_token=a						,      cls_token=a						,      pad_token=a						,      mask_token=a						,      add_prefix_space=a						,      **a						,      )

       with open(a						,      encoding='utf-8'				) as vocab_handle:
        __lowerCamelCase		:							str							=						json.load(a				)
       __lowerCamelCase		:							Optional[int]							=						{v: k for k, v in self.encoder.items()}
       __lowerCamelCase		:							Optional[int]							=						errors  # how to handle errors in decoding
       __lowerCamelCase		:							Union[str, Any]							=						bytes_to_unicode()
       __lowerCamelCase		:							List[str]							=						{v: k for k, v in self.byte_encoder.items()}
       with open(a						,      encoding='utf-8'				) as merges_handle:
        __lowerCamelCase		:							List[str]							=						merges_handle.read().split('\n'				)[1:-1]
       __lowerCamelCase		:							Dict							=						[tuple(merge.split()				) for merge in bpe_merges]
       __lowerCamelCase		:							Optional[Any]							=						dict(zip(a						,      range(len(a				)				)				)				)
       __lowerCamelCase		:							Any							=						{}
       __lowerCamelCase		:							Optional[int]							=						add_prefix_space

       # Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
       __lowerCamelCase		:							int							=						re.compile(R'\'s|\'t|\'re|\'ve|\'m|\'ll|\'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+'				)




      @property
      def      _snake_case	(				self:       Union[str, Any]				):
       return len(self.encoder				)




      def      _snake_case	(				self:       Optional[int]				):
       return dict(self.encoder						,      **self.added_tokens_encoder				)




      def      _snake_case	(				self:       Optional[Any]						,      a:       int				):
       if token in self.cache:
        return self.cache[token]
       __lowerCamelCase		:							Any							=						tuple(a				)
       __lowerCamelCase		:							Optional[Any]							=						get_pairs(a				)

       if not pairs:
        return token

       while True:
        __lowerCamelCase		:							int							=						min(a						,      key=lambda a				: self.bpe_ranks.get(a						,      float('inf'				)				)				)
        if bigram not in self.bpe_ranks:
         break
        __lowerCamelCase					,     __lowerCamelCase		:							int							=						bigram
        __lowerCamelCase		:							Optional[Any]							=						[]
        __lowerCamelCase		:							Any							=						0
        while i < len(a				):
         try:
          __lowerCamelCase		:							List[Any]							=						word.index(a						,      a				)
         except ValueError:
          new_word.extend(word[i:]				)
          break
         else:
          new_word.extend(word[i:j]				)
          __lowerCamelCase		:							int							=						j

         if word[i] == first and i < len(a				) - 1 and word[i + 1] == second:
          new_word.append(first + second				)
          i += 2
         else:
          new_word.append(word[i]				)
          i += 1
        __lowerCamelCase		:							Optional[int]							=						tuple(a				)
        __lowerCamelCase		:							Any							=						new_word
        if len(a				) == 1:
         break
        else:
         __lowerCamelCase		:							Optional[int]							=						get_pairs(a				)
       __lowerCamelCase		:							int							=						' '.join(a				)
       __lowerCamelCase		:							Any							=						word
       return word




      def      _snake_case	(				self:       List[str]						,      a:       Dict				):
       __lowerCamelCase		:							Optional[Any]							=						[]
       for token in re.findall(self.pat						,      a				):
        __lowerCamelCase		:							Optional[int]							=						''.join(
            self.byte_encoder[b] for b in token.encode('utf-8'				)				)  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
        bpe_tokens.extend(bpe_token for bpe_token in self.bpe(a				).split(' '				)				)
       return bpe_tokens




      def      _snake_case	(				self:       Optional[int]						,      a:       Tuple				):
       return self.encoder.get(a						,      self.encoder.get(self.unk_token				)				)




      def      _snake_case	(				self:       Union[str, Any]						,      a:       List[str]				):
       return self.decoder.get(a				)




      def      _snake_case	(				self:       str						,      a:       List[str]				):
       __lowerCamelCase		:							str							=						''.join(a				)
       __lowerCamelCase		:							Tuple							=						bytearray([self.byte_decoder[c] for c in text]				).decode('utf-8'						,      errors=self.errors				)
       return text




      def      _snake_case	(				self:       int						,      a:       str						,      a:       Optional[str] = None				):
       if not os.path.isdir(a				):
        logger.error(F'Vocabulary path ({save_directory}) should be a directory'				)
        return
       __lowerCamelCase		:							Any							=						os.path.join(
           a						,      (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']				)
       __lowerCamelCase		:							int							=						os.path.join(
           a						,      (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['merges_file']				)

       with open(a						,      'w'						,      encoding='utf-8'				) as f:
        f.write(json.dumps(self.encoder						,      indent=2						,      sort_keys=a						,      ensure_ascii=a				) + '\n'				)

       __lowerCamelCase		:							str							=						0
       with open(a						,      'w'						,      encoding='utf-8'				) as writer:
        writer.write('#version: 0.2\n'				)
        for bpe_tokens, token_index in sorted(self.bpe_ranks.items()						,      key=lambda a				: kv[1]				):
         if index != token_index:
          logger.warning(
              F'Saving vocabulary to {merge_file}: BPE merge indices are not consecutive.'
              ' Please check that the tokenizer is not corrupted!'				)
          __lowerCamelCase		:							Dict							=						token_index
         writer.write(' '.join(a				) + '\n'				)
         index += 1

       return vocab_file, merge_file




      def      _snake_case	(				self:       Optional[int]						,      a:       List[int]						,      a:       Optional[List[int]] = None				):
       if token_ids_a is None:
        return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
       __lowerCamelCase		:							Optional[Any]							=						[self.cls_token_id]
       __lowerCamelCase		:							Union[str, Any]							=						[self.sep_token_id]
       return cls + token_ids_a + sep + sep + token_ids_a + sep




      def      _snake_case	(				self:       str						,      a:       List[int]						,      a:       Optional[List[int]] = None						,      a:       bool = False				):
       if already_has_special_tokens:
        return super().get_special_tokens_mask(
            token_ids_a=a						,      token_ids_a=a						,      already_has_special_tokens=a				)

       if token_ids_a is None:
        return [1] + ([0] * len(a				)) + [1]
       return [1] + ([0] * len(a				)) + [1, 1] + ([0] * len(a				)) + [1]




      def      _snake_case	(				self:       int						,      a:       List[int]						,      a:       Optional[List[int]] = None				):
       __lowerCamelCase		:							Optional[Any]							=						[self.sep_token_id]
       __lowerCamelCase		:							List[str]							=						[self.cls_token_id]

       if token_ids_a is None:
        return len(cls + token_ids_a + sep				) * [0]
       return len(cls + token_ids_a + sep + sep + token_ids_a + sep				) * [0]




      def      _snake_case	(				self:       int						,      a:       List[Any]						,      a:       List[str]=False						,      **a:       str				):
       __lowerCamelCase		:							Dict							=						kwargs.pop('add_prefix_space'						,      self.add_prefix_space				)
       if (is_split_into_words or add_prefix_space) and (len(a				) > 0 and not text[0].isspace()):
        __lowerCamelCase		:							str							=						' ' + text
       return (text, kwargs)





from typing import Optional, Tuple

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

from transformers import FLAX_MODEL_MAPPING, FlaxCLIPVisionModel
from transformers.modeling_flax_utils import FlaxPreTrainedModel
from transformers.models.clip.modeling_flax_clip import FlaxCLIPOutput
from transformers.utils import logging


lowercase_           =	logging.get_logger(__name__)


class        A_					(       nn.Module    ):




      '''simple docstring'''


      __snake_case					       =   42
      __snake_case					       =   jnp.floataa




      def      _snake_case	(				self:       List[Any]				):
       __lowerCamelCase		:							Union[str, Any]							=						self.config.text_config
       __lowerCamelCase		:							List[Any]							=						self.config.vision_config

       __lowerCamelCase		:							Any							=						self.config.projection_dim
       __lowerCamelCase		:							Dict							=						text_config.hidden_size
       __lowerCamelCase		:							str							=						vision_config.hidden_size

       __lowerCamelCase		:							Optional[Any]							=						FLAX_MODEL_MAPPING[self.config.text_config.__class__].module_class
       __lowerCamelCase		:							int							=						FLAX_MODEL_MAPPING.get(self.config.vision_config.__class__						,      a				).module_class

       __lowerCamelCase		:							Union[str, Any]							=						text_module(a						,      dtype=self.dtype				)
       __lowerCamelCase		:							int							=						vision_module(a						,      dtype=self.dtype				)

       __lowerCamelCase		:							Union[str, Any]							=						nn.Dense(
           self.projection_dim						,      dtype=self.dtype						,      kernel_init=jax.nn.initializers.normal(0.0_2				)						,      use_bias=a						,      )
       __lowerCamelCase		:							int							=						nn.Dense(
           self.projection_dim						,      dtype=self.dtype						,      kernel_init=jax.nn.initializers.normal(0.0_2				)						,      use_bias=a						,      )
       __lowerCamelCase		:							Dict							=						self.param('logit_scale'						,      jax.nn.initializers.ones						,      []				)




      def __call__(				self:       int						,      a:       Union[str, Any]=None						,      a:       str=None						,      a:       Tuple=None						,      a:       str=None						,      a:       List[Any]=None						,      a:       bool = True						,      a:       List[str]=None						,      a:       Any=None						,      a:       Optional[Any]=None						,      ):
       __lowerCamelCase		:							str							=						return_dict if return_dict is not None else self.config.return_dict

       __lowerCamelCase		:							Any							=						self.vision_model(
           pixel_values=a						,      deterministic=a						,      output_attentions=a						,      output_hidden_states=a						,      return_dict=a						,      )

       __lowerCamelCase		:							Union[str, Any]							=						self.text_model(
           input_ids=a						,      attention_mask=a						,      token_type_ids=a						,      position_ids=a						,      deterministic=a						,      output_attentions=a						,      output_hidden_states=a						,      return_dict=a						,      )

       __lowerCamelCase		:							Tuple							=						vision_outputs[1]
       __lowerCamelCase		:							List[Any]							=						self.visual_projection(a				)

       __lowerCamelCase		:							Any							=						text_outputs[1]
       __lowerCamelCase		:							Optional[Any]							=						self.text_projection(a				)

       # normalized features
       __lowerCamelCase		:							str							=						image_embeds / jnp.linalg.norm(a						,      axis=-1						,      keepdims=a				)
       __lowerCamelCase		:							Optional[int]							=						text_embeds / jnp.linalg.norm(a						,      axis=-1						,      keepdims=a				)

       # cosine similarity as logits
       __lowerCamelCase		:							Union[str, Any]							=						jnp.exp(self.logit_scale				)
       __lowerCamelCase		:							Union[str, Any]							=						jnp.matmul(a						,      image_embeds.T				) * logit_scale
       __lowerCamelCase		:							List[str]							=						logits_per_text.T

       if not return_dict:
        return (logits_per_image, logits_per_text, text_embeds, image_embeds, text_outputs, vision_outputs)

       return FlaxCLIPOutput(
           logits_per_image=a						,      logits_per_text=a						,      text_embeds=a						,      image_embeds=a						,      text_model_output=a						,      vision_model_output=a						,      )



class        A_					(       __UpperCamelCase    ):




      '''simple docstring'''


      __snake_case					       =   HybridCLIPConfig
      __snake_case					       =   FlaxHybridCLIPModule




      def __init__(				self:       List[Any]						,      a:       HybridCLIPConfig						,      a:       Optional[Tuple] = None						,      a:       int = 0						,      a:       jnp.dtype = jnp.floataa						,      **a:       int						,      ):
       if input_shape is None:
        __lowerCamelCase		:							int							=						((1, 1), (1, config.vision_config.image_size, config.vision_config.image_size, 3))

       __lowerCamelCase		:							int							=						self.module_class(config=a						,      dtype=a						,      **a				)
       super().__init__(a						,      a						,      input_shape=a						,      seed=a						,      dtype=a				)




      def      _snake_case	(				self:       Dict						,      a:       jax.random.PRNGKey						,      a:       Tuple						,      a:       FrozenDict = None				):
       # init input tensor
       __lowerCamelCase		:							int							=						jnp.zeros(input_shape[0]						,      dtype='i4'				)
       __lowerCamelCase		:							List[Any]							=						jnp.broadcast_to(jnp.arange(jnp.atleast_ad(a				).shape[-1]				)						,      input_shape[0]				)
       __lowerCamelCase		:							Any							=						jnp.ones_like(a				)
       __lowerCamelCase		:							int							=						jnp.ones_like(a				)

       __lowerCamelCase		:							Optional[Any]							=						jax.random.normal(a						,      input_shape[1]				)

       __lowerCamelCase					,     __lowerCamelCase		:							List[Any]							=						jax.random.split(a				)
       __lowerCamelCase		:							Tuple							=						{'params': params_rng, 'dropout': dropout_rng}

       return self.module.init(a						,      a						,      a						,      a						,      a						,      a				)["params"]




      def __call__(				self:       Tuple						,      a:       Optional[Any]						,      a:       Dict						,      a:       Optional[int]=None						,      a:       Union[str, Any]=None						,      a:       int=None						,      a:       dict = None						,      a:       jax.random.PRNGKey = None						,      a:       bool = False						,      a:       Optional[bool] = None						,      a:       Optional[bool] = None						,      a:       Optional[bool] = None						,      ):
       __lowerCamelCase		:							str							=						output_attentions if output_attentions is not None else self.config.output_attentions
       __lowerCamelCase		:							Dict							=						(
           output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
       )
       __lowerCamelCase		:							int							=						return_dict if return_dict is not None else self.config.return_dict

       if position_ids is None:
        __lowerCamelCase		:							Optional[int]							=						jnp.broadcast_to(jnp.arange(jnp.atleast_ad(a				).shape[-1]				)						,      input_ids.shape				)

       if token_type_ids is None:
        __lowerCamelCase		:							str							=						jnp.zeros_like(a				)

       if attention_mask is None:
        __lowerCamelCase		:							str							=						jnp.ones_like(a				)

       # Handle any PRNG if needed
       __lowerCamelCase		:							Union[str, Any]							=						{}
       if dropout_rng is not None:
        __lowerCamelCase		:							Any							=						dropout_rng

       return self.module.apply(
           {'params': params or self.params}						,      jnp.array(a						,      dtype='i4'				)						,      jnp.array(a						,      dtype=jnp.floataa				)						,      jnp.array(a						,      dtype='i4'				)						,      jnp.array(a						,      dtype='i4'				)						,      jnp.array(a						,      dtype='i4'				)						,      not train						,      a						,      a						,      a						,      rngs=a						,      )




      def      _snake_case	(				self:       Tuple						,      a:       Tuple						,      a:       List[Any]=None						,      a:       Dict=None						,      a:       int=None						,      a:       dict = None						,      a:       jax.random.PRNGKey = None						,      a:       Tuple=False						,      ):
       if position_ids is None:
        __lowerCamelCase		:							str							=						jnp.broadcast_to(jnp.arange(jnp.atleast_ad(a				).shape[-1]				)						,      input_ids.shape				)

       if token_type_ids is None:
        __lowerCamelCase		:							Union[str, Any]							=						jnp.zeros_like(a				)

       if attention_mask is None:
        __lowerCamelCase		:							int							=						jnp.ones_like(a				)

       # Handle any PRNG if needed
       __lowerCamelCase		:							Optional[int]							=						{}
       if dropout_rng is not None:
        __lowerCamelCase		:							List[str]							=						dropout_rng

       def _get_features(a:       str						,      a:       Any						,      a:       Optional[int]						,      a:       Optional[int]						,      a:       Union[str, Any]						,      a:       Optional[int]				):
        __lowerCamelCase		:							Tuple							=						module.text_model(
            input_ids=a						,      attention_mask=a						,      position_ids=a						,      token_type_ids=a						,      deterministic=a						,      )
        __lowerCamelCase		:							int							=						text_outputs[1]
        __lowerCamelCase		:							Optional[Any]							=						module.text_projection(a				)
        return text_features

       return self.module.apply(
           {'params': params or self.params}						,      jnp.array(a						,      dtype='i4'				)						,      jnp.array(a						,      dtype='i4'				)						,      jnp.array(a						,      dtype='i4'				)						,      jnp.array(a						,      dtype='i4'				)						,      not train						,      method=_get_features						,      rngs=a						,      )




      def      _snake_case	(				self:       int						,      a:       Optional[int]						,      a:       dict = None						,      a:       jax.random.PRNGKey = None						,      a:       str=False				):
       __lowerCamelCase		:							Dict							=						{}
       if dropout_rng is not None:
        __lowerCamelCase		:							List[str]							=						dropout_rng

       def _get_features(a:       str						,      a:       Tuple						,      a:       Any				):
        __lowerCamelCase		:							Dict							=						module.vision_model(pixel_values=a						,      deterministic=a				)
        __lowerCamelCase		:							int							=						vision_outputs[1]  # pooled_output
        __lowerCamelCase		:							int							=						module.visual_projection(a				)
        return image_features

       return self.module.apply(
           {'params': params or self.params}						,      jnp.array(a						,      dtype=jnp.floataa				)						,      not train						,      method=_get_features						,      rngs=a						,      )




      @classmethod
      def      _snake_case	(				cls:       str						,      a:       str = None						,      a:       str = None						,      *a:       Optional[Any]						,      **a:       List[str]						,      ):
       __lowerCamelCase		:							List[Any]							=						{
           argument[len('text_'				) :]: value for argument, value in kwargs.items() if argument.startswith('text_'				)
       }

       __lowerCamelCase		:							Optional[Any]							=						{
           argument[len('vision_'				) :]: value for argument, value in kwargs.items() if argument.startswith('vision_'				)
       }

       # remove text, vision kwargs from kwargs
       for key in kwargs_text.keys():
        del kwargs["text_" + key]
       for key in kwargs_vision.keys():
        del kwargs["vision_" + key]

       # Load and initialize the text and vision model
       __lowerCamelCase		:							Any							=						kwargs_text.pop('model'						,      a				)
       if text_model is None:
        assert (
            text_model_name_or_path is not None
        ), "If `model` is not defined as an argument, a `text_model_name_or_path` has to be defined"
        from transformers import FlaxAutoModel

        if "config" not in kwargs_text:
         from transformers import AutoConfig

         __lowerCamelCase		:							Optional[int]							=						AutoConfig.from_pretrained(a				)
         __lowerCamelCase		:							Any							=						text_config

        __lowerCamelCase		:							Dict							=						FlaxAutoModel.from_pretrained(a						,      *a						,      **a				)

       __lowerCamelCase		:							Any							=						kwargs_vision.pop('model'						,      a				)
       if vision_model is None:
        assert (
            vision_model_name_or_path is not None
        ), "If `model` is not defined as an argument, a `vision_model_name_or_path` has to be defined"
        from transformers import FlaxAutoModel

        if "config" not in kwargs_vision:
         from transformers import AutoConfig

         __lowerCamelCase		:							Any							=						AutoConfig.from_pretrained(a				)
         __lowerCamelCase		:							int							=						vision_config

        __lowerCamelCase		:							str							=						FlaxAutoModel.from_pretrained(a						,      *a						,      **a				)

       # instantiate config with corresponding kwargs
       __lowerCamelCase		:							Optional[int]							=						kwargs.pop('dtype'						,      jnp.floataa				)
       __lowerCamelCase		:							List[Any]							=						HybridCLIPConfig.from_text_vision_configs(text_model.config						,      vision_model.config						,      **a				)

       # init model
       __lowerCamelCase		:							List[Any]							=						cls(a						,      *a						,      dtype=a						,      **a				)

       if vision_config.model_type == "clip":
        __lowerCamelCase		:							Any							=						vision_model.params['vision_model']
        __lowerCamelCase		:							Optional[Any]							=						vision_model.params['visual_projection']['kernel']
       else:
        __lowerCamelCase		:							Optional[int]							=						vision_model.params

       __lowerCamelCase		:							List[str]							=						text_model.params

       return model

