

'''simple docstring'''
from typing import List, Optional, Tuple, Union

from . import logging
from .import_utils import is_torch_available, is_torch_version


if is_torch_available():
					import torch

_lowerCamelCase	 =			logging.get_logger(__name__)  # pylint: disable=invalid-name

try:
					from torch._dynamo import allow_in_graph as maybe_allow_in_graph
except (ImportError, ModuleNotFoundError):


					def       a__    (  cls					:    int							)			-> List[str]:


						"""simple docstring"""





						return cls


def       a__    (  _SCREAMING_SNAKE_CASE					:    Union[Tuple, List]     ,							_SCREAMING_SNAKE_CASE					:    Optional[Union[List["torch.Generator"], "torch.Generator"]] = None     ,							_SCREAMING_SNAKE_CASE					:    Optional["torch.device"] = None     ,							_SCREAMING_SNAKE_CASE					:    Optional["torch.dtype"] = None     ,							_SCREAMING_SNAKE_CASE					:    Optional["torch.layout"] = None     ,							)			-> Union[str, Any]:


	"""simple docstring"""





	UpperCAmelCase_			:	Optional[Any]      =   device
	UpperCAmelCase_			:	Optional[int]      =   shape[0]

	UpperCAmelCase_			:	str      =   layout or torch.strided
	UpperCAmelCase_			:	str      =   device or torch.device("cpu"							)

	if generator is not None:
		UpperCAmelCase_			:	str      =   generator.device.type if not isinstance(_SCREAMING_SNAKE_CASE     ,							_SCREAMING_SNAKE_CASE							) else generator[0].device.type
		if gen_device_type != device.type and gen_device_type == "cpu":
			UpperCAmelCase_			:	Any      =   "cpu"
			if device != "mps":
				logger.info(
				    F'''The passed generator was created on \'cpu\' even though a tensor on {device} was expected.'''
				    F''' Tensors will be created on \'cpu\' and then moved to {device}. Note that one can probably'''
				    F''' slighly speed up this function by passing a generator that was created on the {device} device.'''							)
		elif gen_device_type != device.type and gen_device_type == "cuda":
			raise ValueError(F'''Cannot generate a {device} tensor from a generator of type {gen_device_type}.'''							)

	if isinstance(_SCREAMING_SNAKE_CASE     ,							_SCREAMING_SNAKE_CASE							):
		UpperCAmelCase_			:	str      =   (1,) + shape[1:]
		UpperCAmelCase_			:	List[str]      =   [
		    torch.randn(_SCREAMING_SNAKE_CASE     ,							generator=generator[i]     ,							device=_SCREAMING_SNAKE_CASE     ,							dtype=_SCREAMING_SNAKE_CASE     ,							layout=_SCREAMING_SNAKE_CASE							)
		    for i in range(_SCREAMING_SNAKE_CASE							)
		]
		UpperCAmelCase_			:	Optional[Any]      =   torch.cat(_SCREAMING_SNAKE_CASE     ,							dim=0							).to(_SCREAMING_SNAKE_CASE							)
	else:
		UpperCAmelCase_			:	int      =   torch.randn(_SCREAMING_SNAKE_CASE     ,							generator=_SCREAMING_SNAKE_CASE     ,							device=_SCREAMING_SNAKE_CASE     ,							dtype=_SCREAMING_SNAKE_CASE     ,							layout=_SCREAMING_SNAKE_CASE							).to(_SCREAMING_SNAKE_CASE							)

	return latents





def       a__    (  _SCREAMING_SNAKE_CASE					:    Optional[Any]							)			-> Dict:


	"""simple docstring"""





	if is_torch_version("<"     ,							"2.0.0"							) or not hasattr(_SCREAMING_SNAKE_CASE     ,							"_dynamo"							):
		return False
	return isinstance(_SCREAMING_SNAKE_CASE     ,							torch._dynamo.eval_frame.OptimizedModule							)







'''simple docstring'''
def       a__    (  _SCREAMING_SNAKE_CASE					:    list     ,							_SCREAMING_SNAKE_CASE					:    int							)			-> int:


	"""simple docstring"""





	for index, item in enumerate(_SCREAMING_SNAKE_CASE							):
		if item == target:
			return index
	return -1


def       a__    (  _SCREAMING_SNAKE_CASE					:    list     ,							_SCREAMING_SNAKE_CASE					:    int     ,							_SCREAMING_SNAKE_CASE					:    int     ,							_SCREAMING_SNAKE_CASE					:    int							)			-> int:


	"""simple docstring"""





	if not (0 <= high < len(_SCREAMING_SNAKE_CASE							) and 0 <= low < len(_SCREAMING_SNAKE_CASE							)):
		raise Exception("Invalid upper or lower bound!"							)
	if high < low:
		return -1
	if sequence[low] == target:
		return low
	if sequence[high] == target:
		return high
	return rec_linear_search(_SCREAMING_SNAKE_CASE     ,							low + 1     ,							high - 1     ,							_SCREAMING_SNAKE_CASE							)


if __name__ == "__main__":
					_lowerCamelCase	 =			input("""Enter numbers separated by comma:\n""").strip()
					_lowerCamelCase	 =			[int(item.strip()) for item in user_input.split(""",""")]

					_lowerCamelCase	 =			int(input("""Enter a single number to be found in the list:\n""").strip())
					_lowerCamelCase	 =			linear_search(sequence, target)
					if result != -1:
										print(f"""linear_search({sequence}, {target}) = {result}""")
					else:
										print(f"""{target} was not found in {sequence}""")




