





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



class 	lowerCAmelCase					(      unittest.TestCase							):

       '''simple docstring'''





       def __init__(   self    ,  a__    ,  a__=7    ,  a__=3    ,  a__=18    ,  a__=30    ,  a__=4_00    ,  a__=True    ,  a__=None    ,  a__=True    ,  a__=None    ,  ):
              _UpperCAmelCase     =     size if size is not None else {'shortest_edge': 20}
              _UpperCAmelCase     =     crop_size if crop_size is not None else {'height': 18, 'width': 18}
              _UpperCAmelCase     =     parent
              _UpperCAmelCase     =     batch_size
              _UpperCAmelCase     =     num_channels
              _UpperCAmelCase     =     image_size
              _UpperCAmelCase     =     min_resolution
              _UpperCAmelCase     =     max_resolution
              _UpperCAmelCase     =     do_resize
              _UpperCAmelCase     =     size
              _UpperCAmelCase     =     do_center_crop
              _UpperCAmelCase     =     crop_size






       def 							__A (   self     ):
              return {
                  "do_resize": self.do_resize,
                  "size": self.size,
                  "do_center_crop": self.do_center_crop,
                  "crop_size": self.crop_size,
              }



@require_torch
@require_vision
class 	lowerCAmelCase					(      _lowerCAmelCase			,	unittest.TestCase							):

       '''simple docstring'''





       lowerCAmelCase__						 =  MobileNetVaImageProcessor if is_vision_available() else None






       def 							__A (   self     ):
              _UpperCAmelCase     =     MobileNetVaImageProcessingTester(self     )






       @property
       def 							__A (   self     ):
              return self.image_processor_tester.prepare_image_processor_dict()






       def 							__A (   self     ):
              _UpperCAmelCase     =     self.image_processing_class(**self.image_processor_dict     )
              self.assertTrue(hasattr(_lowerCAmelCase    ,  'do_resize'     )     )
              self.assertTrue(hasattr(_lowerCAmelCase    ,  'size'     )     )
              self.assertTrue(hasattr(_lowerCAmelCase    ,  'do_center_crop'     )     )
              self.assertTrue(hasattr(_lowerCAmelCase    ,  'crop_size'     )     )






       def 							__A (   self     ):
              _UpperCAmelCase     =     self.image_processing_class.from_dict(self.image_processor_dict     )
              self.assertEqual(image_processor.size    ,  {'shortest_edge': 20}     )
              self.assertEqual(image_processor.crop_size    ,  {'height': 18, 'width': 18}     )

              _UpperCAmelCase     =     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 							__A (   self     ):
              pass






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

              # Test not batched input
              _UpperCAmelCase     =     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.crop_size['height'],
                      self.image_processor_tester.crop_size['width'],
                  )    ,  )

              # Test batched
              _UpperCAmelCase     =     image_processing(_lowerCAmelCase    ,  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.crop_size['height'],
                      self.image_processor_tester.crop_size['width'],
                  )    ,  )






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

              # Test not batched input
              _UpperCAmelCase     =     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.crop_size['height'],
                      self.image_processor_tester.crop_size['width'],
                  )    ,  )

              # Test batched
              _UpperCAmelCase     =     image_processing(_lowerCAmelCase    ,  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.crop_size['height'],
                      self.image_processor_tester.crop_size['width'],
                  )    ,  )






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

              # Test not batched input
              _UpperCAmelCase     =     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.crop_size['height'],
                      self.image_processor_tester.crop_size['width'],
                  )    ,  )

              # Test batched
              _UpperCAmelCase     =     image_processing(_lowerCAmelCase    ,  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.crop_size['height'],
                      self.image_processor_tester.crop_size['width'],
                  )    ,  )













"""simple docstring"""






from itertools import product

def       __lowerCamelCase    (       SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE							)		->       list[int]:






       """simple docstring"""




       _UpperCAmelCase     =     sides_number
       _UpperCAmelCase     =     max_face_number * dice_number
       _UpperCAmelCase     =     [0] * (max_total + 1)

       _UpperCAmelCase     =     1
       _UpperCAmelCase     =     range(SCREAMING_SNAKE_CASE,max_face_number + 1							)
       for dice_numbers in product(SCREAMING_SNAKE_CASE,repeat=SCREAMING_SNAKE_CASE							):
              _UpperCAmelCase     =     sum(SCREAMING_SNAKE_CASE							)
              totals_frequencies[total] += 1

       return totals_frequencies

def       __lowerCamelCase    (       )		->       float:






       """simple docstring"""




       _UpperCAmelCase     =     total_frequency_distribution(
           sides_number=4,dice_number=9							)
       _UpperCAmelCase     =     total_frequency_distribution(
           sides_number=6,dice_number=6							)

       _UpperCAmelCase     =     0
       _UpperCAmelCase     =     9
       _UpperCAmelCase     =     4 * 9
       _UpperCAmelCase     =     6
       for peter_total in range(SCREAMING_SNAKE_CASE,max_peter_total + 1							):
              peter_wins_count += peter_totals_frequencies[peter_total] * sum(
                  colin_totals_frequencies[min_colin_total:peter_total]							)

       _UpperCAmelCase     =     (4**9) * (6**6)
       _UpperCAmelCase     =     peter_wins_count / total_games_number

       _UpperCAmelCase     =     round(SCREAMING_SNAKE_CASE,ndigits=7							)

       return rounded_peter_win_probability


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






