






import contextlib
import csv
import json
import os
import sqlitea
import tarfile
import textwrap
import zipfile

import pyarrow as pa
import pyarrow.parquet as pq
import pytest

import datasets
import datasets.config
@pytest.fixture(scope='''session''' )
def 						_a    (      )							->			int:
 a		  =      10
 a		  =      datasets.Features(
     {
         '''tokens''': datasets.Sequence(datasets.Value('''string''' ) ),
         '''labels''': datasets.Sequence(datasets.ClassLabel(names=['''negative''', '''positive'''] ) ),
         '''answers''': datasets.Sequence(
             {
                 '''text''': datasets.Value('''string''' ),
                 '''answer_start''': datasets.Value('''int32''' ),
             } ),
         '''id''': datasets.Value('''int64''' ),
     } )
 a		  =      datasets.Dataset.from_dict(
     {
         '''tokens''': [['''foo'''] * 5] * n,
         '''labels''': [[1] * 5] * n,
         '''answers''': [{'''answer_start''': [97], '''text''': ['''1976''']}] * 10,
         '''id''': list(range(a ) ),
     }	,							features=a	,							)
 return dataset
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Optional[Any]	,							a :Tuple )							->			str:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''file.arrow''' )
 dataset.map(cache_file_name=a )
 return filename


# FILE_CONTENT + files


UpperCAmelCase__				   =		"\\n    Text data.\n    Second line of data."
@pytest.fixture(scope='''session''' )
def 						_a    (      a :int )							->			Tuple:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''file.txt'''
 a		  =      FILE_CONTENT
 with open(a	,							'''w''' ) as f:
  f.write(a )
 return filename
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Dict )							->			List[str]:
 import bza

 a		  =      tmp_path_factory.mktemp('''data''' ) / '''file.txt.bz2'''
 a		  =      bytes(a	,							'''utf-8''' )
 with bza.open(a	,							'''wb''' ) as f:
  f.write(a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Tuple )							->			str:
 import gzip

 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''file.txt.gz''' )
 a		  =      bytes(a	,							'''utf-8''' )
 with gzip.open(a	,							'''wb''' ) as f:
  f.write(a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :str )							->			Tuple:
 if datasets.config.LZ4_AVAILABLE:
  import lza.frame

  a		  =      tmp_path_factory.mktemp('''data''' ) / '''file.txt.lz4'''
  a		  =      bytes(a	,							'''utf-8''' )
  with lza.frame.open(a	,							'''wb''' ) as f:
   f.write(a )
  return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :List[str]	,							a :Any )							->			Dict:
 if datasets.config.PY7ZR_AVAILABLE:
  import pyazr

  a		  =      tmp_path_factory.mktemp('''data''' ) / '''file.txt.7z'''
  with pyazr.SevenZipFile(a	,							'''w''' ) as archive:
   archive.write(a	,							arcname=os.path.basename(a ) )
  return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :List[Any]	,							a :Dict )							->			Tuple:
 import tarfile

 a		  =      tmp_path_factory.mktemp('''data''' ) / '''file.txt.tar'''
 with tarfile.TarFile(a	,							'''w''' ) as f:
  f.add(a	,							arcname=os.path.basename(a ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Union[str, Any] )							->			str:
 import lzma

 a		  =      tmp_path_factory.mktemp('''data''' ) / '''file.txt.xz'''
 a		  =      bytes(a	,							'''utf-8''' )
 with lzma.open(a	,							'''wb''' ) as f:
  f.write(a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :List[Any]	,							a :Union[str, Any] )							->			Tuple:
 import zipfile

 a		  =      tmp_path_factory.mktemp('''data''' ) / '''file.txt.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.basename(a ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :List[Any] )							->			Any:
 if datasets.config.ZSTANDARD_AVAILABLE:
  import zstandard as zstd

  a		  =      tmp_path_factory.mktemp('''data''' ) / '''file.txt.zst'''
  a		  =      bytes(a	,							'''utf-8''' )
  with zstd.open(a	,							'''wb''' ) as f:
   f.write(a )
  return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :str )							->			Union[str, Any]:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''file.xml'''
 a		  =      textwrap.dedent(
     '''\
    <?xml version="1.0" encoding="UTF-8" ?>
    <tmx version="1.4">
      <header segtype="sentence" srclang="ca" />
      <body>
        <tu>
          <tuv xml:lang="ca"><seg>Contingut 1</seg></tuv>
          <tuv xml:lang="en"><seg>Content 1</seg></tuv>
        </tu>
        <tu>
          <tuv xml:lang="ca"><seg>Contingut 2</seg></tuv>
          <tuv xml:lang="en"><seg>Content 2</seg></tuv>
        </tu>
        <tu>
          <tuv xml:lang="ca"><seg>Contingut 3</seg></tuv>
          <tuv xml:lang="en"><seg>Content 3</seg></tuv>
        </tu>
        <tu>
          <tuv xml:lang="ca"><seg>Contingut 4</seg></tuv>
          <tuv xml:lang="en"><seg>Content 4</seg></tuv>
        </tu>
        <tu>
          <tuv xml:lang="ca"><seg>Contingut 5</seg></tuv>
          <tuv xml:lang="en"><seg>Content 5</seg></tuv>
        </tu>
      </body>
    </tmx>''' )
 with open(a	,							'''w''' ) as f:
  f.write(a )
 return filename


UpperCAmelCase__				   =		[
    {"col_1": "0", "col_2": 0, "col_3": 0.0},
    {"col_1": "1", "col_2": 1, "col_3": 1.0},
    {"col_1": "2", "col_2": 2, "col_3": 2.0},
    {"col_1": "3", "col_2": 3, "col_3": 3.0},
]
UpperCAmelCase__				   =		[
    {"col_1": "4", "col_2": 4, "col_3": 4.0},
    {"col_1": "5", "col_2": 5, "col_3": 5.0},
]
UpperCAmelCase__				   =		{
    "col_1": ["0", "1", "2", "3"],
    "col_2": [0, 1, 2, 3],
    "col_3": [0.0, 1.0, 2.0, 3.0],
}

UpperCAmelCase__				   =		[
    {"col_3": 0.0, "col_1": "0", "col_2": 0},
    {"col_3": 1.0, "col_1": "1", "col_2": 1},
]

UpperCAmelCase__				   =		[
    {"col_1": "s0", "col_2": 0, "col_3": 0.0},
    {"col_1": "s1", "col_2": 1, "col_3": 1.0},
    {"col_1": "s2", "col_2": 2, "col_3": 2.0},
    {"col_1": "s3", "col_2": 3, "col_3": 3.0},
]
@pytest.fixture(scope='''session''' )
def 						_a    (      )							->			Tuple:
 return DATA_DICT_OF_LISTS
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Union[str, Any] )							->			Optional[Any]:
 a		  =      datasets.Dataset.from_dict(a )
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset.arrow''' )
 dataset.map(cache_file_name=a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Tuple )							->			Optional[Any]:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset.sqlite''' )
 with contextlib.closing(sqlitea.connect(a ) ) as con:
  a		  =      con.cursor()
  cur.execute('''CREATE TABLE dataset(col_1 text, col_2 int, col_3 real)''' )
  for item in DATA:
   cur.execute('''INSERT INTO dataset(col_1, col_2, col_3) VALUES (?, ?, ?)'''	,							tuple(item.values() ) )
  con.commit()
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Union[str, Any] )							->			Union[str, Any]:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset.csv''' )
 with open(a	,							'''w'''	,							newline='''''' ) as f:
  a		  =      csv.DictWriter(a	,							fieldnames=['''col_1''', '''col_2''', '''col_3'''] )
  writer.writeheader()
  for item in DATA:
   writer.writerow(a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Union[str, Any] )							->			str:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset2.csv''' )
 with open(a	,							'''w'''	,							newline='''''' ) as f:
  a		  =      csv.DictWriter(a	,							fieldnames=['''col_1''', '''col_2''', '''col_3'''] )
  writer.writeheader()
  for item in DATA:
   writer.writerow(a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Optional[int]	,							a :Union[str, Any] )							->			List[Any]:
 import bza

 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset.csv.bz2'''
 with open(a	,							'''rb''' ) as f:
  a		  =      f.read()
 # data = bytes(FILE_CONTENT, "utf-8")
 with bza.open(a	,							'''wb''' ) as f:
  f.write(a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Dict	,							a :Optional[Any]	,							a :Optional[int] )							->			int:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset.csv.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.basename(a ) )
  f.write(a	,							arcname=os.path.basename(a ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Union[str, Any]	,							a :List[str]	,							a :List[str] )							->			Tuple:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset.csv.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.basename(csv_path.replace('''.csv'''	,							'''.CSV''' ) ) )
  f.write(a	,							arcname=os.path.basename(csva_path.replace('''.csv'''	,							'''.CSV''' ) ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Any	,							a :Union[str, Any]	,							a :str )							->			List[Any]:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset_with_dir.csv.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.join('''main_dir'''	,							os.path.basename(a ) ) )
  f.write(a	,							arcname=os.path.join('''main_dir'''	,							os.path.basename(a ) ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Any )							->			Any:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset.parquet''' )
 a		  =      pa.schema(
     {
         '''col_1''': pa.string(),
         '''col_2''': pa.intaa(),
         '''col_3''': pa.floataa(),
     } )
 with open(a	,							'''wb''' ) as f:
  a		  =      pq.ParquetWriter(a	,							schema=a )
  a		  =      pa.Table.from_pydict({k: [DATA[i][k] for i in range(len(a ) )] for k in DATA[0]}	,							schema=a )
  writer.write_table(a )
  writer.close()
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :List[Any] )							->			Any:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset.json''' )
 a		  =      {'''data''': DATA}
 with open(a	,							'''w''' ) as f:
  json.dump(a	,							a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Optional[Any] )							->			List[Any]:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset.json''' )
 a		  =      {'''data''': DATA_DICT_OF_LISTS}
 with open(a	,							'''w''' ) as f:
  json.dump(a	,							a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :List[Any] )							->			int:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset.jsonl''' )
 with open(a	,							'''w''' ) as f:
  for item in DATA:
   f.write(json.dumps(a ) + '''\n''' )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Optional[int] )							->			Optional[Any]:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset2.jsonl''' )
 with open(a	,							'''w''' ) as f:
  for item in DATA:
   f.write(json.dumps(a ) + '''\n''' )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Any )							->			Dict:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset_312.jsonl''' )
 with open(a	,							'''w''' ) as f:
  for item in DATA_312:
   f.write(json.dumps(a ) + '''\n''' )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Any )							->			List[str]:
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset-str.jsonl''' )
 with open(a	,							'''w''' ) as f:
  for item in DATA_STR:
   f.write(json.dumps(a ) + '''\n''' )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Union[str, Any]	,							a :int )							->			str:
 import gzip

 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset.txt.gz''' )
 with open(a	,							'''rb''' ) as orig_file:
  with gzip.open(a	,							'''wb''' ) as zipped_file:
   zipped_file.writelines(a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Any	,							a :Union[str, Any] )							->			List[Any]:
 import gzip

 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset.jsonl.gz''' )
 with open(a	,							'''rb''' ) as orig_file:
  with gzip.open(a	,							'''wb''' ) as zipped_file:
   zipped_file.writelines(a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :int	,							a :Optional[Any]	,							a :List[Any] )							->			Union[str, Any]:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset.jsonl.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.basename(a ) )
  f.write(a	,							arcname=os.path.basename(a ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Any	,							a :Dict	,							a :str	,							a :Optional[Any] )							->			str:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset_nested.jsonl.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.join('''nested'''	,							os.path.basename(a ) ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :List[str]	,							a :Optional[int]	,							a :Tuple )							->			int:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset_with_dir.jsonl.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.join('''main_dir'''	,							os.path.basename(a ) ) )
  f.write(a	,							arcname=os.path.join('''main_dir'''	,							os.path.basename(a ) ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Optional[int]	,							a :int	,							a :Optional[Any] )							->			int:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset.jsonl.tar'''
 with tarfile.TarFile(a	,							'''w''' ) as f:
  f.add(a	,							arcname=os.path.basename(a ) )
  f.add(a	,							arcname=os.path.basename(a ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :List[str]	,							a :List[str]	,							a :str	,							a :Tuple )							->			Union[str, Any]:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset_nested.jsonl.tar'''
 with tarfile.TarFile(a	,							'''w''' ) as f:
  f.add(a	,							arcname=os.path.join('''nested'''	,							os.path.basename(a ) ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :List[Any] )							->			Tuple:
 a		  =      ['''0''', '''1''', '''2''', '''3''']
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset.txt''' )
 with open(a	,							'''w''' ) as f:
  for item in data:
   f.write(item + '''\n''' )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Any )							->			List[Any]:
 a		  =      ['''0''', '''1''', '''2''', '''3''']
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset2.txt''' )
 with open(a	,							'''w''' ) as f:
  for item in data:
   f.write(item + '''\n''' )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Union[str, Any] )							->			List[str]:
 a		  =      ['''0''', '''1''', '''2''', '''3''']
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset.abc'''
 with open(a	,							'''w''' ) as f:
  for item in data:
   f.write(item + '''\n''' )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Optional[Any]	,							a :List[str]	,							a :int )							->			List[Any]:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset.text.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.basename(a ) )
  f.write(a	,							arcname=os.path.basename(a ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :List[str]	,							a :int	,							a :Dict )							->			int:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset_with_dir.text.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.join('''main_dir'''	,							os.path.basename(a ) ) )
  f.write(a	,							arcname=os.path.join('''main_dir'''	,							os.path.basename(a ) ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Any	,							a :Tuple	,							a :List[str] )							->			Optional[Any]:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset.ext.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.basename('''unsupported.ext''' ) )
  f.write(a	,							arcname=os.path.basename('''unsupported_2.ext''' ) )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      a :Union[str, Any] )							->			Dict:
 a		  =      '''\n'''.join(['''First''', '''Second\u2029with Unicode new line''', '''Third'''] )
 a		  =      str(tmp_path_factory.mktemp('''data''' ) / '''dataset_with_unicode_new_lines.txt''' )
 with open(a	,							'''w'''	,							encoding='''utf-8''' ) as f:
  f.write(a )
 return path
@pytest.fixture(scope='''session''' )
def 						_a    (      )							->			str:
 return os.path.join('''tests'''	,							'''features'''	,							'''data'''	,							'''test_image_rgb.jpg''' )
@pytest.fixture(scope='''session''' )
def 						_a    (      )							->			Dict:
 return os.path.join('''tests'''	,							'''features'''	,							'''data'''	,							'''test_audio_44100.wav''' )
@pytest.fixture(scope='''session''' )
def 						_a    (      a :int	,							a :int )							->			Optional[int]:
 a		  =      tmp_path_factory.mktemp('''data''' ) / '''dataset.img.zip'''
 with zipfile.ZipFile(a	,							'''w''' ) as f:
  f.write(a	,							arcname=os.path.basename(a ) )
  f.write(a	,							arcname=os.path.basename(a ).replace('''.jpg'''	,							'''2.jpg''' ) )
 return path

@pytest.fixture(scope='''session''' )
def 						_a    (      a :Dict )							->			Dict:
 a		  =      tmp_path_factory.mktemp('''data_dir''' )

 (data_dir / "subdir").mkdir()
 with open(data_dir / '''subdir''' / '''train.txt'''	,							'''w''' ) as f:
  f.write('''foo\n''' * 10 )
 with open(data_dir / '''subdir''' / '''test.txt'''	,							'''w''' ) as f:
  f.write('''bar\n''' * 10 )
 # hidden file
 with open(data_dir / '''subdir''' / '''.test.txt'''	,							'''w''' ) as f:
  f.write('''bar\n''' * 10 )

 # hidden directory
 (data_dir / ".subdir").mkdir()
 with open(data_dir / '''.subdir''' / '''train.txt'''	,							'''w''' ) as f:
  f.write('''foo\n''' * 10 )
 with open(data_dir / '''.subdir''' / '''test.txt'''	,							'''w''' ) as f:
  f.write('''bar\n''' * 10 )

 return data_dir










import copy
import os
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union


if TYPE_CHECKING:
 from ...processing_utils import ProcessorMixin
 from ...utils import TensorType

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowerCamelCase	:							Optional[Any]				=logging.get_logger(__name__)

lowerCamelCase	:							Optional[int]				={
    '''google/owlvit-base-patch32''': '''https://huggingface.co/google/owlvit-base-patch32/resolve/main/config.json''',
    '''google/owlvit-base-patch16''': '''https://huggingface.co/google/owlvit-base-patch16/resolve/main/config.json''',
    '''google/owlvit-large-patch14''': '''https://huggingface.co/google/owlvit-large-patch14/resolve/main/config.json''',
}





class 			__a  (    A__       ):
 _lowerCAmelCase       :       Optional[int]        = '''owlvit_text_model'''







 def __init__(		self					:   Any							,   SCREAMING_SNAKE_CASE					:   Union[str, Any]=4_94_08							,   SCREAMING_SNAKE_CASE					:   List[str]=5_12							,   SCREAMING_SNAKE_CASE					:   List[Any]=20_48							,   SCREAMING_SNAKE_CASE					:   Any=12							,   SCREAMING_SNAKE_CASE					:   Any=8							,   SCREAMING_SNAKE_CASE					:   Dict=16							,   SCREAMING_SNAKE_CASE					:   Union[str, Any]="quick_gelu"							,   SCREAMING_SNAKE_CASE					:   List[str]=1e-5							,   SCREAMING_SNAKE_CASE					:   Union[str, Any]=0.0							,   SCREAMING_SNAKE_CASE					:   Any=0.0_2							,   SCREAMING_SNAKE_CASE					:   int=1.0							,   SCREAMING_SNAKE_CASE					:   Any=0							,   SCREAMING_SNAKE_CASE					:   int=4_94_06							,   SCREAMING_SNAKE_CASE					:   List[str]=4_94_07							,   **SCREAMING_SNAKE_CASE					:   Optional[Any]							,   ):


      '''simple docstring'''






      super().__init__(pad_token_id=SCREAMING_SNAKE_CASE							,   bos_token_id=SCREAMING_SNAKE_CASE							,   eos_token_id=SCREAMING_SNAKE_CASE							,   **SCREAMING_SNAKE_CASE						)

      UpperCamelCase__			:   Tuple       				=  vocab_size
      UpperCamelCase__			:   int       				=  hidden_size
      UpperCamelCase__			:   List[str]       				=  intermediate_size
      UpperCamelCase__			:   Tuple       				=  num_hidden_layers
      UpperCamelCase__			:   str       				=  num_attention_heads
      UpperCamelCase__			:   Any       				=  max_position_embeddings
      UpperCamelCase__			:   List[Any]       				=  hidden_act
      UpperCamelCase__			:   str       				=  layer_norm_eps
      UpperCamelCase__			:   List[Any]       				=  attention_dropout
      UpperCamelCase__			:   Tuple       				=  initializer_range
      UpperCamelCase__			:   Optional[Any]       				=  initializer_factor







 @classmethod
 def 					__lowercase					(		cls					:   Optional[int]							,   SCREAMING_SNAKE_CASE					:   Union[str, os.PathLike]							,   **SCREAMING_SNAKE_CASE					:   Optional[Any]						):


      '''simple docstring'''






      cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE						)

      UpperCamelCase__				,     UpperCamelCase__			:   Any       				=  cls.get_config_dict(SCREAMING_SNAKE_CASE							,   **SCREAMING_SNAKE_CASE						)

      # get the text config dict if we are loading from OwlViTConfig
      if config_dict.get("model_type"						) == "owlvit":
           UpperCamelCase__			:   Dict       				=  config_dict["text_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(SCREAMING_SNAKE_CASE							,   **SCREAMING_SNAKE_CASE						)







class 			__a  (    A__       ):
 _lowerCAmelCase       :       str        = '''owlvit_vision_model'''







 def __init__(		self					:   Optional[int]							,   SCREAMING_SNAKE_CASE					:   str=7_68							,   SCREAMING_SNAKE_CASE					:   Dict=30_72							,   SCREAMING_SNAKE_CASE					:   int=12							,   SCREAMING_SNAKE_CASE					:   Union[str, Any]=12							,   SCREAMING_SNAKE_CASE					:   Dict=3							,   SCREAMING_SNAKE_CASE					:   Union[str, Any]=7_68							,   SCREAMING_SNAKE_CASE					:   Optional[int]=32							,   SCREAMING_SNAKE_CASE					:   Dict="quick_gelu"							,   SCREAMING_SNAKE_CASE					:   Optional[Any]=1e-5							,   SCREAMING_SNAKE_CASE					:   List[str]=0.0							,   SCREAMING_SNAKE_CASE					:   Dict=0.0_2							,   SCREAMING_SNAKE_CASE					:   Optional[int]=1.0							,   **SCREAMING_SNAKE_CASE					:   Tuple							,   ):


      '''simple docstring'''






      super().__init__(**SCREAMING_SNAKE_CASE						)

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







 @classmethod
 def 					__lowercase					(		cls					:   Dict							,   SCREAMING_SNAKE_CASE					:   Union[str, os.PathLike]							,   **SCREAMING_SNAKE_CASE					:   List[Any]						):


      '''simple docstring'''






      cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE						)

      UpperCamelCase__				,     UpperCamelCase__			:   List[Any]       				=  cls.get_config_dict(SCREAMING_SNAKE_CASE							,   **SCREAMING_SNAKE_CASE						)

      # get the vision config dict if we are loading from OwlViTConfig
      if config_dict.get("model_type"						) == "owlvit":
           UpperCamelCase__			:   List[str]       				=  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(SCREAMING_SNAKE_CASE							,   **SCREAMING_SNAKE_CASE						)







class 			__a  (    A__       ):
 _lowerCAmelCase       :       str        = '''owlvit'''
 _lowerCAmelCase       :       Tuple        = True







 def __init__(		self					:   Any							,   SCREAMING_SNAKE_CASE					:   Optional[Any]=None							,   SCREAMING_SNAKE_CASE					:   int=None							,   SCREAMING_SNAKE_CASE					:   str=5_12							,   SCREAMING_SNAKE_CASE					:   Any=2.6_5_9_2							,   SCREAMING_SNAKE_CASE					:   Union[str, Any]=True							,   **SCREAMING_SNAKE_CASE					:   List[Any]							,   ):


      '''simple docstring'''






      super().__init__(**SCREAMING_SNAKE_CASE						)

      if text_config is None:
           UpperCamelCase__			:   str       				=  {}
           logger.info("text_config is None. Initializing the OwlViTTextConfig with default values."						)

      if vision_config is None:
           UpperCamelCase__			:   List[str]       				=  {}
           logger.info("vision_config is None. initializing the OwlViTVisionConfig with default values."						)

      UpperCamelCase__			:   Dict       				=  OwlViTTextConfig(**SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   Dict       				=  OwlViTVisionConfig(**SCREAMING_SNAKE_CASE						)

      UpperCamelCase__			:   Dict       				=  projection_dim
      UpperCamelCase__			:   Union[str, Any]       				=  logit_scale_init_value
      UpperCamelCase__			:   int       				=  return_dict
      UpperCamelCase__			:   Tuple       				=  1.0







 @classmethod
 def 					__lowercase					(		cls					:   Any							,   SCREAMING_SNAKE_CASE					:   Union[str, os.PathLike]							,   **SCREAMING_SNAKE_CASE					:   Dict						):


      '''simple docstring'''






      cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE						)

      UpperCamelCase__				,     UpperCamelCase__			:   Dict       				=  cls.get_config_dict(SCREAMING_SNAKE_CASE							,   **SCREAMING_SNAKE_CASE						)

      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(SCREAMING_SNAKE_CASE							,   **SCREAMING_SNAKE_CASE						)







 @classmethod
 def 					__lowercase					(		cls					:   int							,   SCREAMING_SNAKE_CASE					:   Dict							,   SCREAMING_SNAKE_CASE					:   Dict							,   **SCREAMING_SNAKE_CASE					:   Optional[int]						):


      '''simple docstring'''






      UpperCamelCase__			:   List[Any]       				=  {}
      UpperCamelCase__			:   Union[str, Any]       				=  text_config
      UpperCamelCase__			:   Optional[int]       				=  vision_config

      return cls.from_dict(SCREAMING_SNAKE_CASE							,   **SCREAMING_SNAKE_CASE						)







 def 					__lowercase					(		self					:   Tuple						):


      '''simple docstring'''






      UpperCamelCase__			:   Optional[int]       				=  copy.deepcopy(self.__dict__						)
      UpperCamelCase__			:   Union[str, Any]       				=  self.text_config.to_dict()
      UpperCamelCase__			:   List[str]       				=  self.vision_config.to_dict()
      UpperCamelCase__			:   Optional[int]       				=  self.__class__.model_type
      return output







class 			__a  (    A__       ):







 @property
 def 					__lowercase					(		self					:   Any						):


      '''simple docstring'''






      return OrderedDict(
          [
              ("input_ids", {0: "batch", 1: "sequence"}),
              ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
              ("attention_mask", {0: "batch", 1: "sequence"}),
          ]						)







 @property
 def 					__lowercase					(		self					:   Optional[int]						):


      '''simple docstring'''






      return OrderedDict(
          [
              ("logits_per_image", {0: "batch"}),
              ("logits_per_text", {0: "batch"}),
              ("text_embeds", {0: "batch"}),
              ("image_embeds", {0: "batch"}),
          ]						)







 @property
 def 					__lowercase					(		self					:   Dict						):


      '''simple docstring'''






      return 1e-4







 def 					__lowercase					(		self					:   Optional[int]							,   SCREAMING_SNAKE_CASE					:   "ProcessorMixin"							,   SCREAMING_SNAKE_CASE					:   int = -1							,   SCREAMING_SNAKE_CASE					:   int = -1							,   SCREAMING_SNAKE_CASE					:   Optional["TensorType"] = None							,   ):


      '''simple docstring'''






      UpperCamelCase__			:   Optional[int]       				=  super().generate_dummy_inputs(
          processor.tokenizer							,   batch_size=SCREAMING_SNAKE_CASE							,   seq_length=SCREAMING_SNAKE_CASE							,   framework=SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   List[str]       				=  super().generate_dummy_inputs(
          processor.image_processor							,   batch_size=SCREAMING_SNAKE_CASE							,   framework=SCREAMING_SNAKE_CASE						)
      return {**text_input_dict, **image_input_dict}







 @property
 def 					__lowercase					(		self					:   Tuple						):


      '''simple docstring'''






      return 14