





import argparse
import struct
import unittest





class 			A__   :




   """simple docstring"""



   def __init__( self ,  lowercase)      ->						int:







          '''simple docstring'''

          a__						:     Dict			=    data

          # Initialize hash values
          a__						:     Optional[Any]			=    [
              0x6a_09e_667,
              0xbb_67a_e85,
              0x3c_6ef_372,
              0xa5_4ff_53a,
              0x51_0e5_27f,
              0x9b_056_88c,
              0x1f_83d_9ab,
              0x5b_e0c_d19,
          ]

          # Initialize round constants
          a__						:     Tuple			=    [
              0x42_8a2_f98,
              0x71_374_491,
              0xb5_c0f_bcf,
              0xe9_b5d_ba5,
              0x39_56c_25b,
              0x59_f11_1f1,
              0x92_3f8_2a4,
              0xab_1c5_ed5,
              0xd8_07a_a98,
              0x12_835_b01,
              0x24_318_5be,
              0x55_0c7_dc3,
              0x72_be5_d74,
              0x80_deb_1fe,
              0x9b_dc0_6a7,
              0xc1_9bf_174,
              0xe4_9b6_9c1,
              0xef_be4_786,
              0x0f_c19_dc6,
              0x24_0ca_1cc,
              0x2d_e92_c6f,
              0x4a_748_4aa,
              0x5c_b0a_9dc,
              0x76_f98_8da,
              0x98_3e5_152,
              0xa8_31c_66d,
              0xb0_032_7c8,
              0xbf_597_fc7,
              0xc6_e00_bf3,
              0xd5_a79_147,
              0x06_ca6_351,
              0x14_292_967,
              0x27_b70_a85,
              0x2e_1b2_138,
              0x4d_2c6_dfc,
              0x53_380_d13,
              0x65_0a7_354,
              0x76_6a0_abb,
              0x81_c2c_92e,
              0x92_722_c85,
              0xa2_bfe_8a1,
              0xa8_1a6_64b,
              0xc2_4b8_b70,
              0xc7_6c5_1a3,
              0xd1_92e_819,
              0xd6_990_624,
              0xf4_0e3_585,
              0x10_6aa_070,
              0x19_a4c_116,
              0x1e_376_c08,
              0x27_487_74c,
              0x34_b0b_cb5,
              0x39_1c0_cb3,
              0x4e_d8a_a4a,
              0x5b_9cc_a4f,
              0x68_2e6_ff3,
              0x74_8f8_2ee,
              0x78_a56_36f,
              0x84_c87_814,
              0x8c_c70_208,
              0x90_bef_ffa,
              0xa4_506_ceb,
              0xbe_f9a_3f7,
              0xc6_717_8f2,
          ]

          a__						:     Union[str, Any]			=    self.preprocessing(self.data)
          self.final_hash()

   @staticmethod
   def 							__lowercase		( lowercase)      ->						str:







          '''simple docstring'''

          a__						:     Union[str, Any]			=    B'''\x80''' + (B'''\x00''' * (63 - (len(_lowerCamelCase) + 8) % 64))
          a__						:     Optional[int]			=    struct.pack('>Q' ,  (len(_lowerCamelCase) * 8))
          return data + padding + big_endian_integer

   def 							__lowercase		( self)      ->						Optional[int]:







          '''simple docstring'''

          a__						:     Optional[int]			=    [
              self.preprocessed_data[x : x + 64]
              for x in range(0 ,  len(self.preprocessed_data) ,  64)
          ]

          for block in self.blocks:
                 # Convert the given block into a list of 4 byte integers
                 a__						:     List[str]			=    list(struct.unpack('>16L' ,  _lowerCamelCase))
                 # add 48 0-ed integers
                 words += [0] * 48

                 a__						:     str			=    self.hashes

                 for index in range(0 ,  64):
                        if index > 15:
                               # modify the zero-ed indexes at the end of the array
                               a__						:     int			=    (
                                   self.ror(words[index - 15] ,  7)
                                   ^ self.ror(words[index - 15] ,  18)
                                   ^ (words[index - 15] >> 3)
                               )
                               a__						:     Union[str, Any]			=    (
                                   self.ror(words[index - 2] ,  17)
                                   ^ self.ror(words[index - 2] ,  19)
                                   ^ (words[index - 2] >> 10)
                               )

                               a__						:     List[Any]			=    (
                                   words[index - 16] + sa + words[index - 7] + sa
                               ) % 0x100_000_000

                        # Compression
                        a__						:     Any			=    self.ror(_lowerCamelCase ,  6) ^ self.ror(_lowerCamelCase ,  11) ^ self.ror(_lowerCamelCase ,  25)
                        a__						:     List[Any]			=    (e & f) ^ ((~e & 0xff_fff_fff) & g)
                        a__						:     List[Any]			=    (
                            h + sa + ch + self.round_constants[index] + words[index]
                        ) % 0x100_000_000
                        a__						:     str			=    self.ror(_lowerCamelCase ,  2) ^ self.ror(_lowerCamelCase ,  13) ^ self.ror(_lowerCamelCase ,  22)
                        a__						:     Optional[Any]			=    (a & b) ^ (a & c) ^ (b & c)
                        a__						:     Dict			=    (sa + maj) % 0x100_000_000

                        a__						:     str			=    (
                            g,
                            f,
                            e,
                            ((d + tempa) % 0x100_000_000),
                            c,
                            b,
                            a,
                            ((tempa + tempa) % 0x100_000_000),
                        )

                 a__						:     Optional[Any]			=    [a, b, c, d, e, f, g, h]

                 # Modify final values
                 a__						:     Union[str, Any]			=    [
                     ((element + mutated_hash_values[index]) % 0x100_000_000)
                     for index, element in enumerate(self.hashes)
                 ]

          a__						:     Optional[int]			=    ''''''.join([hex(_lowerCamelCase)[2:].zfill(8) for value in self.hashes])

   def 							__lowercase		( self ,  lowercase ,  lowercase)      ->						Optional[Any]:







          '''simple docstring'''

          return 0xff_fff_fff & (value << (32 - rotations)) | (value >> rotations)





class 			A__   (							unittest.TestCase     ):




   """simple docstring"""



   def 							__lowercase		( self)      ->						Dict:







          '''simple docstring'''

          import hashlib

          a__						:     str			=    bytes('Test String' ,  'utf-8')
          self.assertEqual(SHAaaa(_lowerCamelCase).hash ,  hashlib.shaaaa(_lowerCamelCase).hexdigest())





def A_     (		)  ->		None:
       import doctest

       doctest.testmod()

       a__						:     str			=    argparse.ArgumentParser()
       parser.add_argument(
           '-s'		,				'--string'		,				dest='input_string'		,				default='Hello World!! Welcome to Cryptography'		,				help='Hash the string'		,				)
       parser.add_argument(
           '-f'		,				'--file'		,				dest='input_file'		,				help='Hash contents of a file'    )

       a__						:     Optional[int]			=    parser.parse_args()

       a__						:     Optional[int]			=    args.input_string

       # hash input should be a bytestring
       if args.input_file:
              with open(args.input_file		,				'rb'    ) as f:
                     a__						:     Optional[Any]			=    f.read()
       else:
              a__						:     Optional[Any]			=    bytes(lowerCamelCase__		,				'utf-8'    )

       print(SHAaaa(lowerCamelCase__    ).hash    )


if __name__ == "__main__":
    main()









from __future__ import annotations

import collections
import tempfile
import unittest

import numpy as np

from transformers.testing_utils import require_tf, require_vision, slow
from transformers.utils import is_tf_available, is_vision_available

from ...test_modeling_tf_common import floats_tensor, ids_tensor, random_attention_mask
from ..bert.test_modeling_tf_bert import TFBertModelTester
from ..clip.test_modeling_tf_clip import TFCLIPVisionModelTester
from ..deit.test_modeling_tf_deit import TFDeiTModelTester
from ..roberta.test_modeling_tf_roberta import TFRobertaModelTester
from ..vit.test_modeling_tf_vit import TFViTModelTester


if is_tf_available():
    from transformers import (
        TFBertModel,
        TFCLIPVisionModel,
        TFDeiTModel,
        TFRobertaModel,
        TFVisionTextDualEncoderModel,
        TFViTModel,
        VisionTextDualEncoderConfig,
    )

if is_vision_available():
    from PIL import Image

    from transformers import VisionTextDualEncoderProcessor



def A_     (		A__    )  ->		Dict:
       if isinstance(A__		,				collections.abc.Iterable    ):
              return x
       return (x, x)





@require_tf
class 			A__   :




   """simple docstring"""



   def 							__lowercase		( self ,  lowercase ,  lowercase)      ->						Union[str, Any]:







          '''simple docstring'''

          pass

   def 							__lowercase		( self)      ->						Dict:







          '''simple docstring'''

          pass

   def 							__lowercase		( self)      ->						Dict:







          '''simple docstring'''

          pass

   def 							__lowercase		( self ,  lowercase ,  lowercase ,  lowercase ,  lowercase ,  lowercase=None ,  **lowercase)      ->						List[Any]:







          '''simple docstring'''

          a__						:     Any			=    VisionTextDualEncoderConfig.from_vision_text_configs(lowercase ,  lowercase)

          a__						:     Any			=    TFVisionTextDualEncoderModel(lowercase)

          a__						:     Dict			=    model(input_ids=lowercase ,  pixel_values=lowercase ,  attention_mask=lowercase)

          self.assertEqual(output['text_embeds'].shape ,  (input_ids.shape[0], config.projection_dim))
          self.assertEqual(output['image_embeds'].shape ,  (pixel_values.shape[0], config.projection_dim))

   def 							__lowercase		( self ,  lowercase ,  lowercase ,  lowercase ,  lowercase ,  lowercase=None ,  **lowercase)      ->						List[Any]:







          '''simple docstring'''

          a__			,							a__						:     List[Any]			=    self.get_vision_text_model(lowercase ,  lowercase)
          a__						:     List[str]			=    TFVisionTextDualEncoderModel(vision_model=lowercase ,  text_model=lowercase)

          a__						:     Dict			=    model(input_ids=lowercase ,  pixel_values=lowercase ,  attention_mask=lowercase)

          self.assertEqual(output['text_embeds'].shape ,  (input_ids.shape[0], model.config.projection_dim))
          self.assertEqual(output['image_embeds'].shape ,  (pixel_values.shape[0], model.config.projection_dim))

   def 							__lowercase		( self ,  lowercase ,  lowercase ,  lowercase ,  lowercase ,  lowercase=None ,  **lowercase)      ->						Tuple:







          '''simple docstring'''

          a__			,							a__						:     Any			=    self.get_vision_text_model(lowercase ,  lowercase)
          a__						:     Tuple			=    {'vision_model': vision_model, 'text_model': text_model}
          a__						:     Union[str, Any]			=    TFVisionTextDualEncoderModel.from_vision_text_pretrained(**lowercase)

          a__						:     Any			=    model(input_ids=lowercase ,  pixel_values=lowercase ,  attention_mask=lowercase)

          self.assertEqual(output['text_embeds'].shape ,  (input_ids.shape[0], model.config.projection_dim))
          self.assertEqual(output['image_embeds'].shape ,  (pixel_values.shape[0], model.config.projection_dim))

   def 							__lowercase		( self ,  lowercase ,  lowercase ,  lowercase ,  lowercase ,  lowercase=None ,  **lowercase)      ->						Optional[Any]:







          '''simple docstring'''

          a__			,							a__						:     int			=    self.get_vision_text_model(lowercase ,  lowercase)
          a__						:     List[Any]			=    TFVisionTextDualEncoderModel(vision_model=lowercase ,  text_model=lowercase)

          a__						:     Optional[Any]			=    model(input_ids=lowercase ,  pixel_values=lowercase ,  attention_mask=lowercase)
          a__						:     int			=    output[0].numpy()

          with tempfile.TemporaryDirectory() as tmpdirname:
                 model.save_pretrained(lowercase)
                 a__						:     str			=    TFVisionTextDualEncoderModel.from_pretrained(lowercase)

                 a__						:     List[str]			=    model(input_ids=lowercase ,  pixel_values=lowercase ,  attention_mask=lowercase)
                 a__						:     str			=    after_output[0].numpy()
                 a__						:     str			=    np.amax(np.abs(out_a - out_a))
                 self.assertLessEqual(lowercase ,  1e-5)

   def 							__lowercase		( self ,  lowercase ,  lowercase ,  lowercase ,  lowercase ,  lowercase=None ,  **lowercase)      ->						Optional[int]:







          '''simple docstring'''

          a__			,							a__						:     Optional[Any]			=    self.get_vision_text_model(lowercase ,  lowercase)
          a__						:     Dict			=    TFVisionTextDualEncoderModel(vision_model=lowercase ,  text_model=lowercase)

          a__						:     Optional[int]			=    model(
              input_ids=lowercase ,  pixel_values=lowercase ,  attention_mask=lowercase ,  output_attentions=lowercase)

          a__						:     List[str]			=    output.vision_model_output.attentions
          self.assertEqual(len(lowercase) ,  vision_config.num_hidden_layers)

          # in ViT, the seq_len equals the number of patches + 1 (we add 1 for the [CLS] token)
          a__						:     Optional[Any]			=    to_atuple(vision_model.config.image_size)
          a__						:     Dict			=    to_atuple(vision_model.config.patch_size)
          a__						:     int			=    (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])
          a__						:     List[str]			=    num_patches + 1
          self.assertEqual(vision_attentions[0].shape[-3:] ,  (vision_config.num_attention_heads, seq_len, seq_len))

          a__						:     Union[str, Any]			=    output.text_model_output.attentions
          self.assertEqual(len(lowercase) ,  text_config.num_hidden_layers)

          self.assertEqual(
              text_attentions[0].shape[-3:] ,  (text_config.num_attention_heads, input_ids.shape[-1], input_ids.shape[-1]) ,  )

   def 							__lowercase		( self ,  lowercase ,  lowercase ,  lowercase)      ->						Any:







          '''simple docstring'''

          a__						:     str			=    np.abs((a - b)).max()
          self.assertLessEqual(lowercase ,  lowercase ,  F'Difference between torch and flax is {diff} (>= {tol}).')

   def 							__lowercase		( self)      ->						Optional[Any]:







          '''simple docstring'''

          a__						:     List[Any]			=    self.prepare_config_and_inputs()
          self.check_vision_text_dual_encoder_model(**lowercase)

   def 							__lowercase		( self)      ->						Dict:







          '''simple docstring'''

          a__						:     List[Any]			=    self.prepare_config_and_inputs()
          self.check_model_from_pretrained_configs(**lowercase)

   def 							__lowercase		( self)      ->						Tuple:







          '''simple docstring'''

          a__						:     Any			=    self.prepare_config_and_inputs()
          self.check_vision_text_dual_encoder_from_pretrained(**lowercase)

   def 							__lowercase		( self)      ->						Optional[Any]:







          '''simple docstring'''

          a__						:     int			=    self.prepare_config_and_inputs()
          self.check_save_load(**lowercase)

   def 							__lowercase		( self)      ->						Optional[int]:







          '''simple docstring'''

          a__						:     List[str]			=    self.prepare_config_and_inputs()
          self.check_vision_text_output_attention(**lowercase)

   @slow
   def 							__lowercase		( self)      ->						Union[str, Any]:







          '''simple docstring'''

          a__			,							a__						:     Union[str, Any]			=    self.get_pretrained_model_and_inputs()

          a__						:     Optional[int]			=    model_a(**lowercase)
          a__						:     int			=    outputs[0].numpy()

          with tempfile.TemporaryDirectory() as tmp_dirname:
                 model_a.save_pretrained(lowercase)
                 a__						:     Union[str, Any]			=    TFVisionTextDualEncoderModel.from_pretrained(lowercase)

                 a__						:     int			=    model_a(**lowercase)
                 a__						:     str			=    after_outputs[0].numpy()
                 a__						:     List[Any]			=    np.amax(np.abs(out_a - out_a))
                 self.assertLessEqual(lowercase ,  1e-5)





@require_tf
class 			A__   (							__UpperCAmelCase			,  unittest.TestCase     ):




   """simple docstring"""



   def 							__lowercase		( self)      ->						List[Any]:







          '''simple docstring'''

          a__						:     Any			=    TFVisionTextDualEncoderModel.from_vision_text_pretrained(
              'hf-internal-testing/tiny-random-vit' ,  'hf-internal-testing/tiny-random-bert')
          a__						:     str			=    13
          a__						:     Optional[int]			=    floats_tensor(
              [
                  batch_size,
                  model.vision_model.config.num_channels,
                  model.vision_model.config.image_size,
                  model.vision_model.config.image_size,
              ])
          a__						:     Tuple			=    ids_tensor([batch_size, 4] ,  model.text_model.config.vocab_size)
          a__						:     Optional[int]			=    random_attention_mask([batch_size, 4])
          a__						:     str			=    {'pixel_values': pixel_values, 'input_ids': input_ids, 'attention_mask': attention_mask}

          return model, inputs

   def 							__lowercase		( self ,  lowercase ,  lowercase)      ->						List[Any]:







          '''simple docstring'''

          a__						:     Optional[Any]			=    TFViTModel(lowercase ,  name='vision_model')
          a__						:     Tuple			=    TFBertModel(lowercase ,  name='text_model')
          return vision_model, text_model

   def 							__lowercase		( self)      ->						Any:







          '''simple docstring'''

          a__						:     Tuple			=    TFViTModelTester(self)
          a__						:     int			=    TFBertModelTester(self)
          a__						:     Optional[Any]			=    vit_model_tester.prepare_config_and_inputs()
          a__						:     Any			=    bert_model_tester.prepare_config_and_inputs()

          a__			,							a__			,							a__						:     Optional[int]			=    vision_config_and_inputs

          (
              (
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							
          )						:     Any			=    text_config_and_inputs

          return {
              "text_config": text_config,
              "vision_config": vision_config,
              "pixel_values": pixel_values,
              "attention_mask": input_mask,
              "input_ids": input_ids,
              "text_token_type_ids": token_type_ids,
              "text_sequence_labels": sequence_labels,
              "text_token_labels": token_labels,
              "text_choice_labels": choice_labels,
          }





@require_tf
class 			A__   (							__UpperCAmelCase			,  unittest.TestCase     ):




   """simple docstring"""



   def 							__lowercase		( self)      ->						List[str]:







          '''simple docstring'''

          a__						:     Optional[Any]			=    TFVisionTextDualEncoderModel.from_vision_text_pretrained(
              'Rocketknight1/tiny-random-deit-tf' ,  'hf-internal-testing/tiny-random-roberta')
          a__						:     Union[str, Any]			=    13
          a__						:     Dict			=    floats_tensor(
              [
                  batch_size,
                  model.vision_model.config.num_channels,
                  model.vision_model.config.image_size,
                  model.vision_model.config.image_size,
              ])
          a__						:     Optional[Any]			=    ids_tensor([batch_size, 4] ,  model.text_model.config.vocab_size)
          a__						:     Any			=    random_attention_mask([batch_size, 4])
          a__						:     int			=    {'pixel_values': pixel_values, 'input_ids': input_ids, 'attention_mask': attention_mask}

          return model, inputs

   def 							__lowercase		( self ,  lowercase ,  lowercase ,  lowercase ,  lowercase ,  lowercase=None ,  **lowercase)      ->						Optional[Any]:







          '''simple docstring'''

          a__			,							a__						:     List[Any]			=    self.get_vision_text_model(lowercase ,  lowercase)
          a__						:     Any			=    TFVisionTextDualEncoderModel(vision_model=lowercase ,  text_model=lowercase)

          a__						:     int			=    model(
              input_ids=lowercase ,  pixel_values=lowercase ,  attention_mask=lowercase ,  output_attentions=lowercase)

          a__						:     Optional[Any]			=    output.vision_model_output.attentions
          self.assertEqual(len(lowercase) ,  vision_config.num_hidden_layers)

          # in DEiT, the seq_len equals the number of patches + 2 (we add 2 for the [CLS] and distillation tokens)
          a__						:     Optional[int]			=    to_atuple(vision_model.config.image_size)
          a__						:     str			=    to_atuple(vision_model.config.patch_size)
          a__						:     Tuple			=    (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])
          a__						:     List[str]			=    num_patches + 2
          self.assertEqual(vision_attentions[0].shape[-3:] ,  (vision_config.num_attention_heads, seq_len, seq_len))

          a__						:     List[Any]			=    output.text_model_output.attentions
          self.assertEqual(len(lowercase) ,  text_config.num_hidden_layers)

          self.assertEqual(
              text_attentions[0].shape[-3:] ,  (text_config.num_attention_heads, input_ids.shape[-1], input_ids.shape[-1]) ,  )

   def 							__lowercase		( self ,  lowercase ,  lowercase)      ->						Optional[Any]:







          '''simple docstring'''

          a__						:     List[str]			=    TFDeiTModel(lowercase ,  name='vision_model')
          a__						:     Optional[int]			=    TFRobertaModel(lowercase ,  name='text_model')
          return vision_model, text_model

   def 							__lowercase		( self)      ->						Tuple:







          '''simple docstring'''

          a__						:     Optional[int]			=    TFDeiTModelTester(self)
          a__						:     str			=    TFRobertaModelTester(self)
          a__						:     str			=    vit_model_tester.prepare_config_and_inputs()
          a__						:     Dict			=    bert_model_tester.prepare_config_and_inputs()

          a__			,							a__			,							a__						:     Any			=    vision_config_and_inputs

          (
              (
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							
          )						:     Tuple			=    text_config_and_inputs

          return {
              "text_config": text_config,
              "vision_config": vision_config,
              "pixel_values": pixel_values,
              "attention_mask": input_mask,
              "input_ids": input_ids,
              "text_token_type_ids": token_type_ids,
              "text_sequence_labels": sequence_labels,
              "text_token_labels": token_labels,
              "text_choice_labels": choice_labels,
          }





@require_tf
class 			A__   (							__UpperCAmelCase			,  unittest.TestCase     ):




   """simple docstring"""



   def 							__lowercase		( self)      ->						Any:







          '''simple docstring'''

          a__						:     Dict			=    TFVisionTextDualEncoderModel.from_vision_text_pretrained(
              'Rocketknight1/tiny-random-clip-tf' ,  'hf-internal-testing/tiny-random-bert')
          a__						:     Optional[int]			=    13
          a__						:     Optional[Any]			=    floats_tensor(
              [
                  batch_size,
                  model.vision_model.config.num_channels,
                  model.vision_model.config.image_size,
                  model.vision_model.config.image_size,
              ])
          a__						:     int			=    ids_tensor([batch_size, 4] ,  model.text_model.config.vocab_size)
          a__						:     str			=    random_attention_mask([batch_size, 4])
          a__						:     int			=    {'pixel_values': pixel_values, 'input_ids': input_ids, 'attention_mask': attention_mask}

          return model, inputs

   def 							__lowercase		( self ,  lowercase ,  lowercase)      ->						Optional[Any]:







          '''simple docstring'''

          a__						:     str			=    TFCLIPVisionModel(lowercase ,  name='vision_model')
          a__						:     str			=    TFBertModel(lowercase ,  name='text_model')
          return vision_model, text_model

   def 							__lowercase		( self)      ->						List[Any]:







          '''simple docstring'''

          a__						:     List[str]			=    TFCLIPVisionModelTester(self)
          a__						:     Dict			=    TFBertModelTester(self)
          a__						:     Optional[Any]			=    clip_model_tester.prepare_config_and_inputs()
          a__						:     List[Any]			=    bert_model_tester.prepare_config_and_inputs()

          a__			,							a__						:     Union[str, Any]			=    vision_config_and_inputs

          (
              (
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							(
              a__
          )			,							
          )						:     Optional[int]			=    text_config_and_inputs

          return {
              "text_config": text_config,
              "vision_config": vision_config,
              "pixel_values": pixel_values,
              "attention_mask": input_mask,
              "input_ids": input_ids,
              "text_token_type_ids": token_type_ids,
              "text_sequence_labels": sequence_labels,
              "text_token_labels": token_labels,
              "text_choice_labels": choice_labels,
          }





@require_vision
@require_tf
class 			A__   (							unittest.TestCase     ):




   """simple docstring"""



   @slow
   def 							__lowercase		( self)      ->						Any:







          '''simple docstring'''

          a__						:     Tuple			=    TFVisionTextDualEncoderModel.from_pretrained(
              'clip-italian/clip-italian' ,  logit_scale_init_value=1.0 ,  from_pt=lowercase)
          a__						:     str			=    VisionTextDualEncoderProcessor.from_pretrained('clip-italian/clip-italian')

          a__						:     Tuple			=    Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png')
          a__						:     Optional[Any]			=    processor(
              text=['una foto di un gatto', 'una foto di un cane'] ,  images=lowercase ,  padding=lowercase ,  return_tensors='np')

          a__						:     int			=    model(**lowercase)

          # verify the logits
          self.assertEqual(outputs.logits_per_image.shape ,  (inputs.pixel_values.shape[0], inputs.input_ids.shape[0]))
          self.assertEqual(
              outputs.logits_per_text.shape ,  (inputs.input_ids.shape[0], inputs.pixel_values.shape[0]) ,  )

          a__						:     List[str]			=    np.array([[1.2_28_47_27, 0.3_10_41_22]])

          self.assertTrue(np.allclose(outputs.logits_per_image.numpy() ,  lowercase ,  atol=1e-3))


