



'''simple docstring'''
from __future__ import annotations

import random


class   SCREAMING_SNAKE_CASE__				:
	"""simple docstring"""


	A__    :    int						=				6


	def __init__(		self			) ->							Tuple:
				A:      Union[str, Any]														=   list(range(1					,   Dice.NUM_SIDES + 1			)			)





	def      a__ (		self			) ->							List[str]:
				return random.choice(self.sides			)







def 		_SCREAMING_SNAKE_CASE							(				lowerCamelCase__   :      int							,							lowerCamelCase__   :      int = 2				):


			'''simple docstring'''







			A:      Optional[int]														=   [Dice() for i in range(lowerCamelCase__				)]
			A:      Tuple														=   [0] * (len(lowerCamelCase__				) * Dice.NUM_SIDES + 1)
			for _ in range(lowerCamelCase__				):
						count_of_sum[sum(dice.roll() for dice in dices				)] += 1
			A:      Union[str, Any]														=   [round((count * 100) / num_throws							,							2				) for count in count_of_sum]
			return probability[num_dice:]  # remove probability of sums that never appear


if __name__ == "__main__":
			import doctest

			doctest.testmod()










'''simple docstring'''
import itertools
from dataclasses import dataclass
from typing import Optional

import pyarrow as pa

import datasets
from datasets.table import table_cast


__SCREAMING_SNAKE_CASE :      List[Any]             =datasets.utils.logging.get_logger(__name__)


@dataclass
class   SCREAMING_SNAKE_CASE__				(   datasets.BuilderConfig					):
	"""simple docstring"""


	A__    :    Optional[datasets.Features]						=				None







class   SCREAMING_SNAKE_CASE__				(   datasets.ArrowBasedBuilder					):
	"""simple docstring"""


	A__    :    Optional[int]						=				ArrowConfig


	def      a__ (		self			) ->							Union[str, Any]:
				return datasets.DatasetInfo(features=self.config.features			)


	def      a__ (		self					,   A			) ->							Any:
				if not self.config.data_files:
							raise ValueError(f'At least one data file must be specified, but got data_files={self.config.data_files}'			)
				A:      Tuple														=   dl_manager.download_and_extract(self.config.data_files			)
				if isinstance(A					,   (str, list, tuple)			):
							A:      Union[str, Any]														=   data_files
							if isinstance(A					,   A			):
										A:      Tuple														=   [files]
							# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
							A:      str														=   [dl_manager.iter_files(A			) for file in files]
							return [datasets.SplitGenerator(name=datasets.Split.TRAIN					,   gen_kwargs={"""files""": files}			)]
				A:      Union[str, Any]														=   []
				for split_name, files in data_files.items():
							if isinstance(A					,   A			):
										A:      List[str]														=   [files]
							# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
							A:      List[Any]														=   [dl_manager.iter_files(A			) for file in files]
							# Infer features is they are stoed in the arrow schema
							if self.info.features is None:
										for file in itertools.chain.from_iterable(A			):
													with open(A					,   """rb"""			) as f:
																A:      Dict														=   datasets.Features.from_arrow_schema(pa.ipc.open_stream(A			).schema			)
													break
							splits.append(datasets.SplitGenerator(name=A					,   gen_kwargs={"""files""": files}			)			)
				return splits


	def      a__ (		self					,   A			) ->							pa.Table:
				if self.info.features is not None:
							# more expensive cast to support nested features with keys in a different order
							# allows str <-> int/float or str to Audio for example
							A:      Dict														=   table_cast(A					,   self.info.features.arrow_schema			)
				return pa_table





	def      a__ (		self					,   A			) ->							Dict:
				for file_idx, file in enumerate(itertools.chain.from_iterable(A			)			):
							with open(A					,   """rb"""			) as f:
										try:
													for batch_idx, record_batch in enumerate(pa.ipc.open_stream(A			)			):
																A:      Union[str, Any]														=   pa.Table.from_batches([record_batch]			)
																# Uncomment for debugging (will print the Arrow table size and elements)
																# logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
																# logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
																yield f'{file_idx}_{batch_idx}', self._cast_table(A			)
										except ValueError as e:
													logger.error(f'Failed to read file \'{file}\' with error {type(A			)}: {e}'			)
													raise





