

from __future__ import annotations







def 						_snake_case		(     SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE					)							->   int:

     """simple docstring"""







     _lowerCAmelCase   ,      _lowerCAmelCase :       List[Any]	   =     0, len(SCREAMING_SNAKE_CASE					) - 1
     while start_ind <= end_ind:
          if array[start_ind] == search_item:
               return start_ind
          elif array[end_ind] == search_item:
               return end_ind
          else:
               start_ind += 1
               end_ind -= 1
    # returns -1 if search_item is not found in array
     return -1


if __name__ == "__main__":
  print(double_linear_search(list(range(1_0_0)), 4_0))









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 ConvNextImageProcessor





class A__     (			unittest.TestCase			):



 """simple docstring"""







 def __init__(		self			:						Optional[Any]  ,    A_			:						Union[str, Any]  ,    A_			:						List[Any]=7  ,    A_			:						Optional[Any]=3  ,    A_			:						Optional[int]=1_8  ,    A_			:						Dict=3_0  ,    A_			:						Dict=4_0_0  ,    A_			:						List[Any]=True  ,    A_			:						int=None  ,    A_			:						List[Any]=0.875  ,    A_			:						List[str]=True  ,    A_			:						List[Any]=[0.5, 0.5, 0.5]  ,    A_			:						Optional[Any]=[0.5, 0.5, 0.5]  ,    ):






      '''simple docstring'''




      _lowerCAmelCase :       List[str]	   =     size if size is not None else {"shortest_edge": 2_0}
      _lowerCAmelCase :       Union[str, Any]	   =     parent
      _lowerCAmelCase :       int	   =     batch_size
      _lowerCAmelCase :       Any	   =     num_channels
      _lowerCAmelCase :       str	   =     image_size
      _lowerCAmelCase :       List[Any]	   =     min_resolution
      _lowerCAmelCase :       Tuple	   =     max_resolution
      _lowerCAmelCase :       Any	   =     do_resize
      _lowerCAmelCase :       List[str]	   =     size
      _lowerCAmelCase :       List[str]	   =     crop_pct
      _lowerCAmelCase :       Tuple	   =     do_normalize
      _lowerCAmelCase :       int	   =     image_mean
      _lowerCAmelCase :       Dict	   =     image_std


 def  __magic_name__							(		self			:						Dict							):






      '''simple docstring'''




      return {
          "image_mean": self.image_mean,
          "image_std": self.image_std,
          "do_normalize": self.do_normalize,
          "do_resize": self.do_resize,
          "size": self.size,
          "crop_pct": self.crop_pct,
      }





@require_torch
@require_vision
class A__     (			A	,		unittest.TestCase			):



 """simple docstring"""







 _lowercase  :       int  			=    ConvNextImageProcessor if is_vision_available() else None

 def  __magic_name__							(		self			:						Dict							):






      '''simple docstring'''




      _lowerCAmelCase :       int	   =     ConvNextImageProcessingTester(self							)

 @property
 def  __magic_name__							(		self			:						str							):






      '''simple docstring'''




      return self.image_processor_tester.prepare_image_processor_dict()

 def  __magic_name__							(		self			:						Union[str, Any]							):






      '''simple docstring'''




      _lowerCAmelCase :       int	   =     self.image_processing_class(**self.image_processor_dict							)
      self.assertTrue(hasattr(A_  ,    "do_resize"							)							)
      self.assertTrue(hasattr(A_  ,    "size"							)							)
      self.assertTrue(hasattr(A_  ,    "crop_pct"							)							)
      self.assertTrue(hasattr(A_  ,    "do_normalize"							)							)
      self.assertTrue(hasattr(A_  ,    "image_mean"							)							)
      self.assertTrue(hasattr(A_  ,    "image_std"							)							)

 def  __magic_name__							(		self			:						Optional[int]							):






      '''simple docstring'''




      _lowerCAmelCase :       str	   =     self.image_processing_class.from_dict(self.image_processor_dict							)
      self.assertEqual(image_processor.size  ,    {"shortest_edge": 2_0}							)

      _lowerCAmelCase :       Optional[int]	   =     self.image_processing_class.from_dict(self.image_processor_dict  ,    size=4_2							)
      self.assertEqual(image_processor.size  ,    {"shortest_edge": 4_2}							)

 def  __magic_name__							(		self			:						List[str]							):






      '''simple docstring'''




      pass

 def  __magic_name__							(		self			:						Tuple							):






      '''simple docstring'''




      _lowerCAmelCase :       Optional[int]	   =     self.image_processing_class(**self.image_processor_dict							)
      # create random PIL images
      _lowerCAmelCase :       Tuple	   =     prepare_image_inputs(self.image_processor_tester  ,    equal_resolution=A_							)
      for image in image_inputs:
           self.assertIsInstance(A_  ,    Image.Image							)

      # Test not batched input
      _lowerCAmelCase :       List[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["shortest_edge"],
              self.image_processor_tester.size["shortest_edge"],
          )  ,    )

      # Test batched
      _lowerCAmelCase :       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["shortest_edge"],
              self.image_processor_tester.size["shortest_edge"],
          )  ,    )

 def  __magic_name__							(		self			:						Optional[int]							):






      '''simple docstring'''




      _lowerCAmelCase :       Dict	   =     self.image_processing_class(**self.image_processor_dict							)
      # create random numpy tensors
      _lowerCAmelCase :       str	   =     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
      _lowerCAmelCase :       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["shortest_edge"],
              self.image_processor_tester.size["shortest_edge"],
          )  ,    )

      # Test batched
      _lowerCAmelCase :       Optional[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["shortest_edge"],
              self.image_processor_tester.size["shortest_edge"],
          )  ,    )


 def  __magic_name__							(		self			:						List[Any]							):






      '''simple docstring'''




      _lowerCAmelCase :       Tuple	   =     self.image_processing_class(**self.image_processor_dict							)
      # create random PyTorch tensors
      _lowerCAmelCase :       List[str]	   =     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
      _lowerCAmelCase :       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["shortest_edge"],
              self.image_processor_tester.size["shortest_edge"],
          )  ,    )

      # Test batched
      _lowerCAmelCase :       Union[str, 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["shortest_edge"],
              self.image_processor_tester.size["shortest_edge"],
          )  ,    )






