


"""simple docstring"""





import sys
from collections.abc import Mapping
from typing import TYPE_CHECKING

import numpy as np
import pyarrow as pa

from .. import config
from ..utils.py_utils import map_nested
from .formatting import TensorFormatter


if TYPE_CHECKING:
    import torch



class 		snake_case_(       TensorFormatter[Mapping, '''torch.Tensor''', Mapping]			):






     def __init__(	self  :					str					,				UpperCamelCase_  :					int=None					,				**UpperCamelCase_  :					str				):
           super().__init__(features=UpperCamelCase_				)
           lowerCAmelCase					:	Dict       =   torch_tensor_kwargs
           import torch  # noqa import torch at initialization






     def      lowerCamelCase__     (	self  :					str					,				UpperCamelCase_  :					int				):
           import torch

           if isinstance(UpperCamelCase_					,				UpperCamelCase_				) and column:
                 if all(
                     isinstance(UpperCamelCase_					,				torch.Tensor				) and x.shape == column[0].shape and x.dtype == column[0].dtype
                     for x in column				):
                       return torch.stack(UpperCamelCase_				)
           return column






     def      lowerCamelCase__     (	self  :					Optional[Any]					,				UpperCamelCase_  :					Optional[int]				):
           import torch

           if isinstance(UpperCamelCase_					,				(str, bytes, type(UpperCamelCase_				))				):
                 return value
           elif isinstance(UpperCamelCase_					,				(np.character, np.ndarray)				) and np.issubdtype(value.dtype					,				np.character				):
                 return value.tolist()

           lowerCAmelCase					:	str       =   {}

           if isinstance(UpperCamelCase_					,				(np.number, np.ndarray)				) and np.issubdtype(value.dtype					,				np.integer				):
                 lowerCAmelCase					:	List[Any]       =   {'''dtype''': torch.intaa}
           elif isinstance(UpperCamelCase_					,				(np.number, np.ndarray)				) and np.issubdtype(value.dtype					,				np.floating				):
                 lowerCAmelCase					:	Optional[Any]       =   {'''dtype''': torch.floataa}
           elif config.PIL_AVAILABLE and "PIL" in sys.modules:
                 import PIL.Image

                 if isinstance(UpperCamelCase_					,				PIL.Image.Image				):
                       lowerCAmelCase					:	Dict       =   np.asarray(UpperCamelCase_				)
           return torch.tensor(UpperCamelCase_					,				**{**default_dtype, **self.torch_tensor_kwargs}				)






     def      lowerCamelCase__     (	self  :					Dict					,				UpperCamelCase_  :					str				):
           import torch

           # support for torch, tf, jax etc.
           if hasattr(UpperCamelCase_					,				'''__array__'''				) and not isinstance(UpperCamelCase_					,				torch.Tensor				):
                 lowerCAmelCase					:	List[Any]       =   data_struct.__array__()
           # support for nested types like struct of list of struct
           if isinstance(UpperCamelCase_					,				np.ndarray				):
                 if data_struct.dtype == object:  # torch tensors cannot be instantied from an array of objects
                       return self._consolidate([self.recursive_tensorize(UpperCamelCase_				) for substruct in data_struct]				)
           elif isinstance(UpperCamelCase_					,				(list, tuple)				):
                 return self._consolidate([self.recursive_tensorize(UpperCamelCase_				) for substruct in data_struct]				)
           return self._tensorize(UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Any					,				UpperCamelCase_  :					dict				):
           return map_nested(self._recursive_tensorize					,				UpperCamelCase_					,				map_list=UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					List[Any]					,				UpperCamelCase_  :					pa.Table				):
           lowerCAmelCase					:	List[str]       =   self.numpy_arrow_extractor().extract_row(UpperCamelCase_				)
           lowerCAmelCase					:	Optional[int]       =   self.python_features_decoder.decode_row(UpperCamelCase_				)
           return self.recursive_tensorize(UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Optional[int]					,				UpperCamelCase_  :					pa.Table				):
           lowerCAmelCase					:	Dict       =   self.numpy_arrow_extractor().extract_column(UpperCamelCase_				)
           lowerCAmelCase					:	Optional[Any]       =   self.python_features_decoder.decode_column(UpperCamelCase_					,				pa_table.column_names[0]				)
           lowerCAmelCase					:	Dict       =   self.recursive_tensorize(UpperCamelCase_				)
           lowerCAmelCase					:	Optional[int]       =   self._consolidate(UpperCamelCase_				)
           return column






     def      lowerCamelCase__     (	self  :					Union[str, Any]					,				UpperCamelCase_  :					pa.Table				):
           lowerCAmelCase					:	List[str]       =   self.numpy_arrow_extractor().extract_batch(UpperCamelCase_				)
           lowerCAmelCase					:	List[str]       =   self.python_features_decoder.decode_batch(UpperCamelCase_				)
           lowerCAmelCase					:	List[Any]       =   self.recursive_tensorize(UpperCamelCase_				)
           for column_name in batch:
                 lowerCAmelCase					:	Union[str, Any]       =   self._consolidate(batch[column_name]				)
           return batch






"""simple docstring"""





from __future__ import annotations


def      _snake_case						(						_snake_case				:			list[int] ,   _snake_case				:			int			):
      if len(_snake_case			) == 0:
            return False
      lowerCAmelCase					:	List[Any]       =   len(_snake_case			) // 2
      if a_list[midpoint] == item:
            return True
      if item < a_list[midpoint]:
            return binary_search(a_list[:midpoint] ,   _snake_case			)
      else:
            return binary_search(a_list[midpoint + 1 :] ,   _snake_case			)


if __name__ == "__main__":
 snake_case__		:     List[str]    				=				input('''Enter numbers separated by comma:\n''').strip()
 snake_case__		:     Optional[int]    				=				[int(item.strip()) for item in user_input.split(''',''')]
 snake_case__		:     Dict    				=				int(input('''Enter the number to be found in the list:\n''').strip())
 snake_case__		:     str    				=				'''''' if binary_search(sequence, target) else '''not '''
 print(f"""{target} was {not_str}found in {sequence}""")


