

"""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_video_inputs


if is_torch_available():
    import torch

if is_vision_available():
    from PIL import Image

    from transformers import VideoMAEImageProcessor






class  __a				(	unittest.TestCase					):





       """simple docstring"""


       def __init__(      self ,				snake_case ,				snake_case=7 ,				snake_case=3 ,				snake_case=10 ,				snake_case=18 ,				snake_case=30 ,				snake_case=400 ,				snake_case=True ,				snake_case=None ,				snake_case=True ,				snake_case=[0.5, 0.5, 0.5] ,				snake_case=[0.5, 0.5, 0.5] ,				snake_case=None ,				):





        """simple docstring"""

        lowerCAmelCase__      :							Optional[int]    =							size if size is not None else {'shortest_edge': 18}
        lowerCAmelCase__      :							Union[str, Any]    =							crop_size if crop_size is not None else {'height': 18, 'width': 18}

        lowerCAmelCase__      :							List[Any]    =							parent
        lowerCAmelCase__      :							int    =							batch_size
        lowerCAmelCase__      :							List[Any]    =							num_channels
        lowerCAmelCase__      :							Optional[Any]    =							num_frames
        lowerCAmelCase__      :							Union[str, Any]    =							image_size
        lowerCAmelCase__      :							Dict    =							min_resolution
        lowerCAmelCase__      :							List[str]    =							max_resolution
        lowerCAmelCase__      :							Dict    =							do_resize
        lowerCAmelCase__      :							int    =							size
        lowerCAmelCase__      :							str    =							do_normalize
        lowerCAmelCase__      :							Optional[int]    =							image_mean
        lowerCAmelCase__      :							Any    =							image_std
        lowerCAmelCase__      :							Tuple    =							crop_size






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """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_size": self.crop_size,
        }






@require_torch
@require_vision
class  __a				(	a__					,  unittest.TestCase					):





       """simple docstring"""


       __UpperCamelCase				:			List[str]          =	VideoMAEImageProcessor if is_vision_available() else None






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

        lowerCAmelCase__      :							Any    =							VideoMAEImageProcessingTester(self      )






       @property
       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

        return self.image_processor_tester.prepare_image_processor_dict()






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

        lowerCAmelCase__      :							Optional[Any]    =							self.image_processing_class(**self.image_processor_dict      )
        self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_ ,				"image_mean"      )      )
        self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_ ,				"image_std"      )      )
        self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_ ,				"do_normalize"      )      )
        self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_ ,				"do_resize"      )      )
        self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_ ,				"do_center_crop"      )      )
        self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_ ,				"size"      )      )






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

        lowerCAmelCase__      :							Tuple    =							self.image_processing_class.from_dict(self.image_processor_dict      )
        self.assertEqual(image_processor.size ,				{"shortest_edge": 18}      )
        self.assertEqual(image_processor.crop_size ,				{"height": 18, "width": 18}      )

        lowerCAmelCase__      :							Any    =							self.image_processing_class.from_dict(self.image_processor_dict ,				size=42 ,				crop_size=84      )
        self.assertEqual(image_processor.size ,				{"shortest_edge": 42}      )
        self.assertEqual(image_processor.crop_size ,				{"height": 84, "width": 84}      )






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

        pass






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

        lowerCAmelCase__      :							List[Any]    =							self.image_processing_class(**self.image_processor_dict      )
        # create random PIL videos
        lowerCAmelCase__      :							Dict    =							prepare_video_inputs(self.image_processor_tester ,				equal_resolution=SCREAMING_SNAKE_CASE_      )
        for video in video_inputs:
         self.assertIsInstance(SCREAMING_SNAKE_CASE_ ,				SCREAMING_SNAKE_CASE_      )
         self.assertIsInstance(video[0] ,				Image.Image      )

        # Test not batched input
        lowerCAmelCase__      :							str    =							image_processing(video_inputs[0] ,				return_tensors="pt"      ).pixel_values
        self.assertEqual(
            encoded_videos.shape ,				(
                1,
                self.image_processor_tester.num_frames,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["height"],
                self.image_processor_tester.crop_size["width"],
            ) ,				)

        # Test batched
        lowerCAmelCase__      :							str    =							image_processing(SCREAMING_SNAKE_CASE_ ,				return_tensors="pt"      ).pixel_values
        self.assertEqual(
            encoded_videos.shape ,				(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_frames,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["height"],
                self.image_processor_tester.crop_size["width"],
            ) ,				)






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

        lowerCAmelCase__      :							Union[str, Any]    =							self.image_processing_class(**self.image_processor_dict      )
        # create random numpy tensors
        lowerCAmelCase__      :							Optional[Any]    =							prepare_video_inputs(self.image_processor_tester ,				equal_resolution=SCREAMING_SNAKE_CASE_ ,				numpify=SCREAMING_SNAKE_CASE_      )
        for video in video_inputs:
         self.assertIsInstance(SCREAMING_SNAKE_CASE_ ,				SCREAMING_SNAKE_CASE_      )
         self.assertIsInstance(video[0] ,				np.ndarray      )

        # Test not batched input
        lowerCAmelCase__      :							int    =							image_processing(video_inputs[0] ,				return_tensors="pt"      ).pixel_values
        self.assertEqual(
            encoded_videos.shape ,				(
                1,
                self.image_processor_tester.num_frames,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["height"],
                self.image_processor_tester.crop_size["width"],
            ) ,				)

        # Test batched
        lowerCAmelCase__      :							Optional[Any]    =							image_processing(SCREAMING_SNAKE_CASE_ ,				return_tensors="pt"      ).pixel_values
        self.assertEqual(
            encoded_videos.shape ,				(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_frames,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["height"],
                self.image_processor_tester.crop_size["width"],
            ) ,				)






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

        lowerCAmelCase__      :							List[Any]    =							self.image_processing_class(**self.image_processor_dict      )
        # create random PyTorch tensors
        lowerCAmelCase__      :							Optional[int]    =							prepare_video_inputs(self.image_processor_tester ,				equal_resolution=SCREAMING_SNAKE_CASE_ ,				torchify=SCREAMING_SNAKE_CASE_      )
        for video in video_inputs:
         self.assertIsInstance(SCREAMING_SNAKE_CASE_ ,				SCREAMING_SNAKE_CASE_      )
         self.assertIsInstance(video[0] ,				torch.Tensor      )

        # Test not batched input
        lowerCAmelCase__      :							List[Any]    =							image_processing(video_inputs[0] ,				return_tensors="pt"      ).pixel_values
        self.assertEqual(
            encoded_videos.shape ,				(
                1,
                self.image_processor_tester.num_frames,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["height"],
                self.image_processor_tester.crop_size["width"],
            ) ,				)

        # Test batched
        lowerCAmelCase__      :							Optional[Any]    =							image_processing(SCREAMING_SNAKE_CASE_ ,				return_tensors="pt"      ).pixel_values
        self.assertEqual(
            encoded_videos.shape ,				(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_frames,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["height"],
                self.image_processor_tester.crop_size["width"],
            ) ,				)









"""simple docstring"""

from itertools import product



def 			SCREAMING_SNAKE_CASE       (   lowercase__ = 1_5      ) ->	int:
 lowerCAmelCase__      :							float    =							0.0
 lowerCAmelCase__      :							float
 lowerCAmelCase__      :							int
 lowerCAmelCase__      :							int
 lowerCAmelCase__      :							int
 lowerCAmelCase__      :							int
 lowerCAmelCase__      :							tuple[int, ...]

 for series in product(range(2      )				,				repeat=lowercase__      ):
  lowerCAmelCase__      :							Optional[int]    =							series.count(1      )
  lowerCAmelCase__      :							Dict    =							num_turns - num_blue
  if num_red >= num_blue:
   continue
  lowerCAmelCase__      :							Dict    =							1.0
  for ind, col in enumerate(lowercase__				,				2      ):
   if col == 0:
    prob *= (ind - 1) / ind
   else:
    prob *= 1 / ind

  total_prob += prob

 return int(1 / total_prob      )


if __name__ == "__main__":
    print(f"{solution() = }")






