
"""simple docstring"""
import copy
import importlib.metadata
import json
import os
from dataclasses import dataclass
from typing import Any, Dict, Union

from packaging import version

from ..utils import is_torch_available, logging


if is_torch_available():
      import torch


lowercase_							:    Optional[Any]         =						logging.get_logger(__name__)
@dataclass
class       UpperCamelCase   :
     def __init__(  self	,  snake_case__=False	,  snake_case__=False	,  snake_case__=6.0	,  snake_case__=None	,  snake_case__=False	,  snake_case__=False	,  snake_case__=None	,  snake_case__="fp4"	,  snake_case__=False	,  **snake_case__	,  ):




       """simple docstring"""


       _SCREAMING_SNAKE_CASE :					Tuple				     =			load_in_abit
       _SCREAMING_SNAKE_CASE :					Any				     =			load_in_abit
       _SCREAMING_SNAKE_CASE :					Optional[int]				     =			llm_inta_threshold
       _SCREAMING_SNAKE_CASE :					str				     =			llm_inta_skip_modules
       _SCREAMING_SNAKE_CASE :					Union[str, Any]				     =			llm_inta_enable_fpaa_cpu_offload
       _SCREAMING_SNAKE_CASE :					Optional[int]				     =			llm_inta_has_fpaa_weight
       _SCREAMING_SNAKE_CASE :					Dict				     =			bnb_abit_quant_type
       _SCREAMING_SNAKE_CASE :					int				     =			bnb_abit_use_double_quant

       if bnb_abit_compute_dtype is None:
         _SCREAMING_SNAKE_CASE :					Union[str, Any]				     =			torch.floataa
       elif isinstance(__SCREAMING_SNAKE_CASE	,  __SCREAMING_SNAKE_CASE					):
         _SCREAMING_SNAKE_CASE :					List[Any]				     =			getattr(__SCREAMING_SNAKE_CASE	,  __SCREAMING_SNAKE_CASE					)
       elif isinstance(__SCREAMING_SNAKE_CASE	,  torch.dtype					):
         _SCREAMING_SNAKE_CASE :					List[str]				     =			bnb_abit_compute_dtype
       else:
         raise ValueError("bnb_4bit_compute_dtype must be a string or a torch.dtype"					)

       self.post_init()
     def 					__SCREAMING_SNAKE_CASE				(  self					):




       """simple docstring"""


       if not isinstance(self.llm_inta_threshold	,  __SCREAMING_SNAKE_CASE					):
         raise ValueError("llm_int8_threshold must be a float"					)

       if self.llm_inta_skip_modules is not None and not isinstance(self.llm_inta_skip_modules	,  __SCREAMING_SNAKE_CASE					):
         raise ValueError("llm_int8_skip_modules must be a list of strings"					)
       if not isinstance(self.llm_inta_enable_fpaa_cpu_offload	,  __SCREAMING_SNAKE_CASE					):
         raise ValueError("llm_int8_enable_fp32_cpu_offload must be a boolean"					)

       if not isinstance(self.llm_inta_has_fpaa_weight	,  __SCREAMING_SNAKE_CASE					):
         raise ValueError("llm_int8_has_fp16_weight must be a boolean"					)

       if self.bnb_abit_compute_dtype is not None and not isinstance(self.bnb_abit_compute_dtype	,  torch.dtype					):
         raise ValueError("bnb_4bit_compute_dtype must be torch.dtype"					)

       if not isinstance(self.bnb_abit_quant_type	,  __SCREAMING_SNAKE_CASE					):
         raise ValueError("bnb_4bit_quant_type must be a string"					)

       if not isinstance(self.bnb_abit_use_double_quant	,  __SCREAMING_SNAKE_CASE					):
         raise ValueError("bnb_4bit_use_double_quant must be a boolean"					)

       if self.load_in_abit and not version.parse(importlib.metadata.version("bitsandbytes"					)					) >= version.parse(
           "0.39.0"					):
         raise ValueError(
             "4 bit quantization requires bitsandbytes>=0.39.0 - please upgrade your bitsandbytes version"					)
     def 					__SCREAMING_SNAKE_CASE				(  self					):




       """simple docstring"""


       return self.load_in_abit or self.load_in_abit
     def 					__SCREAMING_SNAKE_CASE				(  self					):




       """simple docstring"""


       if self.load_in_abit:
         return "llm_int8"
       elif self.load_in_abit and self.bnb_abit_quant_type == "fp4":
         return "fp4"
       elif self.load_in_abit and self.bnb_abit_quant_type == "nf4":
         return "nf4"
       else:
         return None
     @classmethod
     def 					__SCREAMING_SNAKE_CASE				(  cls	,  snake_case__	,  snake_case__	,  **snake_case__					):




       """simple docstring"""


       _SCREAMING_SNAKE_CASE :					Tuple				     =			cls(**__SCREAMING_SNAKE_CASE					)

       _SCREAMING_SNAKE_CASE :					Optional[int]				     =			[]
       for key, value in kwargs.items():
         if hasattr(__SCREAMING_SNAKE_CASE	,  __SCREAMING_SNAKE_CASE					):
           setattr(__SCREAMING_SNAKE_CASE	,  __SCREAMING_SNAKE_CASE	,  __SCREAMING_SNAKE_CASE					)
           to_remove.append(__SCREAMING_SNAKE_CASE					)
       for key in to_remove:
         kwargs.pop(__SCREAMING_SNAKE_CASE	,  __SCREAMING_SNAKE_CASE					)

       if return_unused_kwargs:
         return config, kwargs
       else:
         return config
     def 					__SCREAMING_SNAKE_CASE				(  self	,  snake_case__					):




       """simple docstring"""


       with open(__SCREAMING_SNAKE_CASE	,  "w"	,  encoding="utf-8"					) as writer:
         _SCREAMING_SNAKE_CASE :					Any				     =			self.to_dict()
         _SCREAMING_SNAKE_CASE :					List[str]				     =			json.dumps(__SCREAMING_SNAKE_CASE	,  indent=2	,  sort_keys=__SCREAMING_SNAKE_CASE					) + "\n"

         writer.write(__SCREAMING_SNAKE_CASE					)
     def 					__SCREAMING_SNAKE_CASE				(  self					):




       """simple docstring"""


       _SCREAMING_SNAKE_CASE :					Optional[Any]				     =			copy.deepcopy(self.__dict__					)
       _SCREAMING_SNAKE_CASE :					List[Any]				     =			str(output["bnb_4bit_compute_dtype"]					).split("."					)[1]

       return output
     def __repr__(  self					):




       """simple docstring"""


       return F'''{self.__class__.__name__} {self.to_json_string()}'''
     def 					__SCREAMING_SNAKE_CASE				(  self	,  snake_case__ = True					):




       """simple docstring"""


       if use_diff is True:
         _SCREAMING_SNAKE_CASE :					List[str]				     =			self.to_diff_dict()
       else:
         _SCREAMING_SNAKE_CASE :					List[Any]				     =			self.to_dict()
       return json.dumps(__SCREAMING_SNAKE_CASE	,  indent=2	,  sort_keys=__SCREAMING_SNAKE_CASE					) + "\n"




     def 					__SCREAMING_SNAKE_CASE				(  self					):




       """simple docstring"""


       _SCREAMING_SNAKE_CASE :					Dict				     =			self.to_dict()

       # get the default config dict
       _SCREAMING_SNAKE_CASE :					Optional[int]				     =			BitsAndBytesConfig().to_dict()

       _SCREAMING_SNAKE_CASE :					Tuple				     =			{}

       # only serialize values that differ from the default config
       for key, value in config_dict.items():
         if value != default_config_dict[key]:
           _SCREAMING_SNAKE_CASE :					Union[str, Any]				     =			value

       return serializable_config_dict





"""simple docstring"""




from itertools import product



def     __magic_name__		(					UpperCamelCase     :		int							,		UpperCamelCase     :		int     )     ->						list[int]:
    a__		=			sides_number
    a__		=			max_face_number * dice_number
    a__		=			[0] * (max_total + 1)

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

    return totals_frequencies



def     __magic_name__		(					)     ->						float:
    a__		=			total_frequency_distribution(
        sides_number=4							,		dice_number=9     )
    a__		=			total_frequency_distribution(
        sides_number=6							,		dice_number=6     )

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

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

    a__		=			round(UpperCamelCase							,		ndigits=7     )

    return rounded_peter_win_probability


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


