





import unittest

import numpy as np

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

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 DPTImageProcessor

class    _UpperCAmelCase							(		unittest.TestCase     ):
      def __init__(		self      ,       a__      ,       a__=7      ,       a__=3      ,       a__=18      ,       a__=30      ,       a__=400      ,       a__=True      ,       a__=None      ,       a__=True      ,       a__=[0.5, 0.5, 0.5]      ,       a__=[0.5, 0.5, 0.5]      ,       ):
         A_     :				Dict			      =	size if size is not None else {"""height""": 18, """width""": 18}
         A_     :				Tuple			      =	parent
         A_     :				List[Any]			      =	batch_size
         A_     :				Tuple			      =	num_channels
         A_     :				Optional[Any]			      =	image_size
         A_     :				int			      =	min_resolution
         A_     :				Optional[Any]			      =	max_resolution
         A_     :				Any			      =	do_resize
         A_     :				List[Any]			      =	size
         A_     :				Dict			      =	do_normalize
         A_     :				Any			      =	image_mean
         A_     :				Optional[int]			      =	image_std






      def 		_lowerCamelCase      (		self       ):
         return {
             "image_mean": self.image_mean,
             "image_std": self.image_std,
             "do_normalize": self.do_normalize,
             "do_resize": self.do_resize,
             "size": self.size,
         }






@require_torch
@require_vision
class    _UpperCAmelCase							(		_lowerCamelCase			,       unittest.TestCase     ):
      a						       =							DPTImageProcessor if is_vision_available() else None
      def 		_lowerCamelCase      (		self       ):
         A_     :				List[str]			      =	DPTImageProcessingTester(self       )
      @property
      def 		_lowerCamelCase      (		self       ):
         return self.image_processor_tester.prepare_image_processor_dict()
      def 		_lowerCamelCase      (		self       ):
         A_     :				Union[str, Any]			      =	self.image_processing_class(**self.image_processor_dict       )
         self.assertTrue(hasattr(a__      ,       """image_mean"""       )       )
         self.assertTrue(hasattr(a__      ,       """image_std"""       )       )
         self.assertTrue(hasattr(a__      ,       """do_normalize"""       )       )
         self.assertTrue(hasattr(a__      ,       """do_resize"""       )       )
         self.assertTrue(hasattr(a__      ,       """size"""       )       )
      def 		_lowerCamelCase      (		self       ):
         A_     :				str			      =	self.image_processing_class.from_dict(self.image_processor_dict       )
         self.assertEqual(image_processor.size      ,       {"""height""": 18, """width""": 18}       )

         A_     :				Optional[Any]			      =	self.image_processing_class.from_dict(self.image_processor_dict      ,       size=42       )
         self.assertEqual(image_processor.size      ,       {"""height""": 42, """width""": 42}       )
      def 		_lowerCamelCase      (		self       ):
         # Initialize image_processing
         A_     :				Optional[int]			      =	self.image_processing_class(**self.image_processor_dict       )
         # create random PIL images
         A_     :				List[str]			      =	prepare_image_inputs(self.image_processor_tester      ,       equal_resolution=a__       )
         for image in image_inputs:
            self.assertIsInstance(a__      ,       Image.Image       )

         # Test not batched input
         A_     :				Union[str, Any]			      =	image_processing(image_inputs[0]      ,       return_tensors="""pt"""       ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,       (
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""height"""],
                 self.image_processor_tester.size["""width"""],
             )      ,       )

         # Test batched
         A_     :				Dict			      =	image_processing(a__      ,       return_tensors="""pt"""       ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,       (
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""height"""],
                 self.image_processor_tester.size["""width"""],
             )      ,       )
      def 		_lowerCamelCase      (		self       ):
         # Initialize image_processing
         A_     :				str			      =	self.image_processing_class(**self.image_processor_dict       )
         # create random numpy tensors
         A_     :				int			      =	prepare_image_inputs(self.image_processor_tester      ,       equal_resolution=a__      ,       numpify=a__       )
         for image in image_inputs:
            self.assertIsInstance(a__      ,       np.ndarray       )

         # Test not batched input
         A_     :				str			      =	image_processing(image_inputs[0]      ,       return_tensors="""pt"""       ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,       (
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""height"""],
                 self.image_processor_tester.size["""width"""],
             )      ,       )

         # Test batched
         A_     :				Any			      =	image_processing(a__      ,       return_tensors="""pt"""       ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,       (
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""height"""],
                 self.image_processor_tester.size["""width"""],
             )      ,       )






      def 		_lowerCamelCase      (		self       ):
         # Initialize image_processing
         A_     :				Any			      =	self.image_processing_class(**self.image_processor_dict       )
         # create random PyTorch tensors
         A_     :				Union[str, Any]			      =	prepare_image_inputs(self.image_processor_tester      ,       equal_resolution=a__      ,       torchify=a__       )
         for image in image_inputs:
            self.assertIsInstance(a__      ,       torch.Tensor       )

         # Test not batched input
         A_     :				int			      =	image_processing(image_inputs[0]      ,       return_tensors="""pt"""       ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,       (
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""height"""],
                 self.image_processor_tester.size["""width"""],
             )      ,       )

         # Test batched
         A_     :				List[str]			      =	image_processing(a__      ,       return_tensors="""pt"""       ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,       (
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size["""height"""],
                 self.image_processor_tester.size["""width"""],
             )      ,       )













import re



def     _lowerCAmelCase		(  _lowerCAmelCase     ):
   '''simple docstring'''


   A_     :				Any			      =	re.compile(r"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$"""     )
   if match := re.search(_lowerCAmelCase  ,_lowerCAmelCase     ):
      return match.string == phone
   return False


if __name__ == "__main__":
      print(indian_phone_validator("""+918827897895"""))






