






'''simple docstring'''







import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import GLPNImageProcessor




class   __SCREAMING_SNAKE_CASE       (unittest.TestCase       ):


  """simple docstring"""


  def __init__(			self   ,	UpperCamelCase__   ,	UpperCamelCase__=7   ,	UpperCamelCase__=3   ,	UpperCamelCase__=18   ,	UpperCamelCase__=30   ,	UpperCamelCase__=400   ,	UpperCamelCase__=True   ,	UpperCamelCase__=32   ,	UpperCamelCase__=True   ,	):






         """simple docstring"""


         a_						     =			parent
         a_						     =			batch_size
         a_						     =			num_channels
         a_						     =			image_size
         a_						     =			min_resolution
         a_						     =			max_resolution
         a_						     =			do_resize
         a_						     =			size_divisor
         a_						     =			do_rescale







  def    _a       (			self	):






         """simple docstring"""


         return {
             "do_resize": self.do_resize,
             "size_divisor": self.size_divisor,
             "do_rescale": self.do_rescale,
         }





@require_torch
@require_vision
class   __SCREAMING_SNAKE_CASE       (__A							,       unittest.TestCase       ):


  """simple docstring"""


  _a  : Union[str, Any]      			=     GLPNImageProcessor if is_vision_available() else None







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			GLPNImageProcessingTester(self	)







  @property
  def    _a       (			self	):






         """simple docstring"""


         return self.image_processor_tester.prepare_image_processor_dict()







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.image_processing_class(**self.image_processor_dict	)
         self.assertTrue(hasattr(UpperCamelCase__   ,	'do_resize'	)	)
         self.assertTrue(hasattr(UpperCamelCase__   ,	'size_divisor'	)	)
         self.assertTrue(hasattr(UpperCamelCase__   ,	'resample'	)	)
         self.assertTrue(hasattr(UpperCamelCase__   ,	'do_rescale'	)	)







  def    _a       (			self	):






         """simple docstring"""


         pass







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.image_processing_class(**self.image_processor_dict	)
         # create random PIL images
         a_						     =			prepare_image_inputs(self.image_processor_tester   ,	equal_resolution=UpperCamelCase__	)
         for image in image_inputs:
                self.assertIsInstance(UpperCamelCase__   ,	Image.Image	)

         # Test not batched input (GLPNImageProcessor doesn't support batching)
         a_						     =			image_processing(image_inputs[0]   ,	return_tensors='pt'	).pixel_values
         self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0	)
         self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.image_processing_class(**self.image_processor_dict	)
         # create random numpy tensors
         a_						     =			prepare_image_inputs(self.image_processor_tester   ,	equal_resolution=UpperCamelCase__   ,	numpify=UpperCamelCase__	)
         for image in image_inputs:
                self.assertIsInstance(UpperCamelCase__   ,	np.ndarray	)

         # Test not batched input (GLPNImageProcessor doesn't support batching)
         a_						     =			image_processing(image_inputs[0]   ,	return_tensors='pt'	).pixel_values
         self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0	)
         self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.image_processing_class(**self.image_processor_dict	)
         # create random PyTorch tensors
         a_						     =			prepare_image_inputs(self.image_processor_tester   ,	equal_resolution=UpperCamelCase__   ,	torchify=UpperCamelCase__	)
         for image in image_inputs:
                self.assertIsInstance(UpperCamelCase__   ,	torch.Tensor	)

         # Test not batched input (GLPNImageProcessor doesn't support batching)
         a_						     =			image_processing(image_inputs[0]   ,	return_tensors='pt'	).pixel_values
         self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0	)
         self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0	)












'''simple docstring'''







import os
import sys
import unittest


__lowerCAmelCase        =							os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, "utils"))

import get_test_info  # noqa: E402
from get_test_info import (  # noqa: E402
    get_model_to_test_mapping,
    get_model_to_tester_mapping,
    get_test_to_tester_mapping,
)


__lowerCAmelCase        =							os.path.join("tests", "models", "bert", "test_modeling_bert.py")
__lowerCAmelCase        =							os.path.join("tests", "models", "blip", "test_modeling_blip.py")




class   __SCREAMING_SNAKE_CASE       (unittest.TestCase       ):


  """simple docstring"""


  def    _a       (			self	):






         """simple docstring"""


         a_						     =			get_test_to_tester_mapping(UpperCamelCase__	)
         a_						     =			get_test_to_tester_mapping(UpperCamelCase__	)

         a_						     =			{'BertModelTest': 'BertModelTester'}

         a_						     =			{
             'BlipModelTest': 'BlipModelTester',
             'BlipTextImageModelTest': 'BlipTextImageModelsModelTester',
             'BlipTextModelTest': 'BlipTextModelTester',
             'BlipTextRetrievalModelTest': 'BlipTextRetrievalModelTester',
             'BlipVQAModelTest': 'BlipVQAModelTester',
             'BlipVisionModelTest': 'BlipVisionModelTester',
         }

         self.assertEqual(get_test_info.to_json(UpperCamelCase__	)   ,	UpperCamelCase__	)
         self.assertEqual(get_test_info.to_json(UpperCamelCase__	)   ,	UpperCamelCase__	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			get_model_to_test_mapping(UpperCamelCase__	)
         a_						     =			get_model_to_test_mapping(UpperCamelCase__	)

         a_						     =			{
             'BertForMaskedLM': ['BertModelTest'],
             'BertForMultipleChoice': ['BertModelTest'],
             'BertForNextSentencePrediction': ['BertModelTest'],
             'BertForPreTraining': ['BertModelTest'],
             'BertForQuestionAnswering': ['BertModelTest'],
             'BertForSequenceClassification': ['BertModelTest'],
             'BertForTokenClassification': ['BertModelTest'],
             'BertLMHeadModel': ['BertModelTest'],
             'BertModel': ['BertModelTest'],
         }

         a_						     =			{
             'BlipForConditionalGeneration': ['BlipTextImageModelTest'],
             'BlipForImageTextRetrieval': ['BlipTextRetrievalModelTest'],
             'BlipForQuestionAnswering': ['BlipVQAModelTest'],
             'BlipModel': ['BlipModelTest'],
             'BlipTextModel': ['BlipTextModelTest'],
             'BlipVisionModel': ['BlipVisionModelTest'],
         }

         self.assertEqual(get_test_info.to_json(UpperCamelCase__	)   ,	UpperCamelCase__	)
         self.assertEqual(get_test_info.to_json(UpperCamelCase__	)   ,	UpperCamelCase__	)







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			get_model_to_tester_mapping(UpperCamelCase__	)
         a_						     =			get_model_to_tester_mapping(UpperCamelCase__	)

         a_						     =			{
             'BertForMaskedLM': ['BertModelTester'],
             'BertForMultipleChoice': ['BertModelTester'],
             'BertForNextSentencePrediction': ['BertModelTester'],
             'BertForPreTraining': ['BertModelTester'],
             'BertForQuestionAnswering': ['BertModelTester'],
             'BertForSequenceClassification': ['BertModelTester'],
             'BertForTokenClassification': ['BertModelTester'],
             'BertLMHeadModel': ['BertModelTester'],
             'BertModel': ['BertModelTester'],
         }

         a_						     =			{
             'BlipForConditionalGeneration': ['BlipTextImageModelsModelTester'],
             'BlipForImageTextRetrieval': ['BlipTextRetrievalModelTester'],
             'BlipForQuestionAnswering': ['BlipVQAModelTester'],
             'BlipModel': ['BlipModelTester'],
             'BlipTextModel': ['BlipTextModelTester'],
             'BlipVisionModel': ['BlipVisionModelTester'],
         }

         self.assertEqual(get_test_info.to_json(UpperCamelCase__	)   ,	UpperCamelCase__	)
         self.assertEqual(get_test_info.to_json(UpperCamelCase__	)   ,	UpperCamelCase__	)




