'''simple docstring'''




import builtins
import sys

from ...utils.imports import _is_package_available
from . import cursor, input
from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor
from .keymap import KEYMAP


_lowercase						: Dict						=						False
try:
						_lowercase						: Union[str, Any]						=						_is_package_available("google.colab")
except ModuleNotFoundError:
						pass





@input.register
class     __magic_name__						:







			def __init__(	self				:  Optional[int]				,			lowercase_				:  List[str] = None				,			lowercase_				:  Any = []    ):
										lowercase_					:			Optional[int]										=       0
										lowercase_					:			Optional[int]										=       choices
										lowercase_					:			List[Any]										=       prompt
										if sys.platform == "win32":
																	lowercase_					:			List[Any]										=       '*'
										else:
																	lowercase_					:			Union[str, Any]										=       '➔ '







			def 	SCREAMING_SNAKE_CASE_     (	self				:  Dict				,			lowercase_				:  Any				,			lowercase_				:  Optional[int] = ""    ):





										if sys.platform != "win32":
																	writeColor(self.choices[index]				,			32				,			__a    )
										else:
																	forceWrite(self.choices[index]				,			__a    )







			def 	SCREAMING_SNAKE_CASE_     (	self				:  int				,			lowercase_				:  str    ):





										if index == self.position:
																	forceWrite(f''' {self.arrow_char} '''    )
																	self.write_choice(__a    )
										else:
																	forceWrite(f'''    {self.choices[index]}'''    )
										reset_cursor()







			def 	SCREAMING_SNAKE_CASE_     (	self				:  Any				,			lowercase_				:  Tuple				,			lowercase_				:  str = 1    ):
										lowercase_					:			List[Any]										=       self.position
										if direction == Direction.DOWN:
																	if self.position + 1 >= len(self.choices    ):
																								return
																	self.position += num_spaces
										else:
																	if self.position - 1 < 0:
																								return
																	self.position -= num_spaces
										clear_line()
										self.print_choice(__a    )
										move_cursor(__a				,			direction.name    )
										self.print_choice(self.position    )







			@input.mark(KEYMAP["""up"""]    )
			def 	SCREAMING_SNAKE_CASE_     (	self				:  List[str]    ):
										self.move_direction(Direction.UP    )







			@input.mark(KEYMAP["""down"""]    )
			def 	SCREAMING_SNAKE_CASE_     (	self				:  List[Any]    ):
										self.move_direction(Direction.DOWN    )







			@input.mark(KEYMAP["""newline"""]    )
			def 	SCREAMING_SNAKE_CASE_     (	self				:  Union[str, Any]    ):
										move_cursor(len(self.choices    ) - self.position				,			"""DOWN"""    )
										return self.position







			@input.mark(KEYMAP["""interrupt"""]    )
			def 	SCREAMING_SNAKE_CASE_     (	self				:  Union[str, Any]    ):
										move_cursor(len(self.choices    ) - self.position				,			"""DOWN"""    )
										raise KeyboardInterrupt







			@input.mark_multiple(*[KEYMAP[str(__a    )] for number in range(10    )]    )
			def 	SCREAMING_SNAKE_CASE_     (	self				:  str    ):
										lowercase_					:			List[Any]										=       int(chr(self.current_selection    )    )
										lowercase_					:			Any										=       index - self.position
										if index == self.position:
																	return
										if index < len(self.choices    ):
																	if self.position > index:
																								self.move_direction(Direction.UP				,			-movement    )
																	elif self.position < index:
																								self.move_direction(Direction.DOWN				,			__a    )
																	else:
																								return
										else:
																	return







			def 	SCREAMING_SNAKE_CASE_     (	self				:  Any				,			lowercase_				:  Any = 0    ):





										if self.prompt:
																	linebreak()
																	forceWrite(self.prompt				,			"""\n"""    )
																	if in_colab:
																								forceWrite("""Please input a choice index (starting from 0), and press enter"""				,			"""\n"""    )
																	else:
																								forceWrite("""Please select a choice using the arrow or number keys, and selecting with enter"""				,			"""\n"""    )
										lowercase_					:			str										=       default_choice
										for i in range(len(self.choices    )    ):
																	self.print_choice(__a    )
																	forceWrite("""\n"""    )
										move_cursor(len(self.choices    ) - self.position				,			"""UP"""    )
										with cursor.hide():
																	while True:
																								if in_colab:
																															try:
																																						lowercase_					:			List[Any]										=       int(builtins.input()    )
																															except ValueError:
																																						lowercase_					:			Any										=       default_choice
																								else:
																															lowercase_					:			List[Any]										=       self.handle_input()
																								if choice is not None:
																															reset_cursor()
																															for _ in range(len(self.choices    ) + 1    ):
																																						move_cursor(1				,			"""UP"""    )
																																						clear_line()
																															self.write_choice(__a				,			"""\n"""    )
																															return choice









'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__lowercase	:						Union[str, Any]       =	{
    'configuration_blenderbot': [
        'BLENDERBOT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'BlenderbotConfig',
        'BlenderbotOnnxConfig',
    ],
    'tokenization_blenderbot': ['BlenderbotTokenizer'],
}

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase	:						List[Any]       =	['BlenderbotTokenizerFast']

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase	:						List[Any]       =	[
	    'BLENDERBOT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'BlenderbotForCausalLM',
	    'BlenderbotForConditionalGeneration',
	    'BlenderbotModel',
	    'BlenderbotPreTrainedModel',
	]


try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase	:						Union[str, Any]       =	[
	    'TFBlenderbotForConditionalGeneration',
	    'TFBlenderbotModel',
	    'TFBlenderbotPreTrainedModel',
	]


try:
	if not is_flax_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase	:						Dict       =	[
	    'FlaxBlenderbotForConditionalGeneration',
	    'FlaxBlenderbotModel',
	    'FlaxBlenderbotPreTrainedModel',
	]


if TYPE_CHECKING:
	from .configuration_blenderbot import (
	    BLENDERBOT_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    BlenderbotConfig,
	    BlenderbotOnnxConfig,
	)
	from .tokenization_blenderbot import BlenderbotTokenizer

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_blenderbot_fast import BlenderbotTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_blenderbot import (
		    BLENDERBOT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    BlenderbotForCausalLM,
		    BlenderbotForConditionalGeneration,
		    BlenderbotModel,
		    BlenderbotPreTrainedModel,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_blenderbot import (
		    TFBlenderbotForConditionalGeneration,
		    TFBlenderbotModel,
		    TFBlenderbotPreTrainedModel,
		)

	try:
		if not is_flax_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_flax_blenderbot import (
		    FlaxBlenderbotForConditionalGeneration,
		    FlaxBlenderbotModel,
		    FlaxBlenderbotPreTrainedModel,
		)

else:
	import sys

	__lowercase	:						str       =	_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)



