






"""simple docstring"""
from typing import Callable, Optional

from .. import Features
from ..packaged_modules.generator.generator import Generator
from .abc import AbstractDatasetInputStream



class      SCREAMING_SNAKE_CASE  (				UpperCAmelCase__						):





	"""simple docstring"""




	def __init__(self     ,     lowerCAmelCase_     ,     lowerCAmelCase_ = None     ,     lowerCAmelCase_ = None     ,     lowerCAmelCase_ = False     ,     lowerCAmelCase_ = False     ,     lowerCAmelCase_ = None     ,     lowerCAmelCase_ = None     ,     **lowerCAmelCase_     ,     ):
		super().__init__(
		    features=lowerCamelCase__     ,     cache_dir=lowerCamelCase__     ,     keep_in_memory=lowerCamelCase__     ,     streaming=lowerCamelCase__     ,     num_proc=lowerCamelCase__     ,     **lowerCamelCase__     ,     )
		A_		:						Tuple	    =   Generator(
		    cache_dir=lowerCamelCase__     ,     features=lowerCamelCase__     ,     generator=lowerCamelCase__     ,     gen_kwargs=lowerCamelCase__     ,     **lowerCamelCase__     ,     )





	def    lowerCamelCase(self							):







		if self.streaming:
			A_		:						int	    =   self.builder.as_streaming_dataset(split="""train"""							)
		# Build regular (map-style) dataset
		else:
			A_		:						Dict	    =   None
			A_		:						str	    =   None
			A_		:						List[Any]	    =   None
			A_		:						Union[str, Any]	    =   None

			self.builder.download_and_prepare(
			    download_config=lowerCamelCase__     ,     download_mode=lowerCamelCase__     ,     verification_mode=lowerCamelCase__     ,     base_path=lowerCamelCase__     ,     num_proc=self.num_proc     ,     )
			A_		:						List[Any]	    =   self.builder.as_dataset(
			    split="""train"""     ,     verification_mode=lowerCamelCase__     ,     in_memory=self.keep_in_memory							)
		return dataset









"""simple docstring"""
def 			__UpperCamelCase	(		snake_case__   ,   snake_case__   ,   snake_case__					):
	return not any(
	    neighbour == 1 and colored_vertices[i] == color
	    for i, neighbour in enumerate(snake_case__					)					)






def 			__UpperCamelCase	(		snake_case__   ,   snake_case__   ,   snake_case__   ,   snake_case__					):

	# Base Case
	if index == len(snake_case__					):
		return True

	# Recursive Step
	for i in range(snake_case__					):
		if valid_coloring(graph[index]   ,   snake_case__   ,   snake_case__					):
			# Color current vertex
			A_		:						Dict	    =   i
			# Validate coloring
			if util_color(snake_case__   ,   snake_case__   ,   snake_case__   ,   index + 1					):
				return True
			# Backtrack
			A_		:						Union[str, Any]	    =   -1
	return False






def 			__UpperCamelCase	(		snake_case__   ,   snake_case__					):
	A_		:						int	    =   [-1] * len(snake_case__					)

	if util_color(snake_case__   ,   snake_case__   ,   snake_case__   ,   0					):
		return colored_vertices

	return []

