




'''simple docstring'''






import sys
from collections.abc import Mapping

import numpy as np
import pyarrow as pa

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






class 					lowercase_			(	TensorFormatter[Mapping, np.ndarray, Mapping]       ):





     def __init__(    self    :				Optional[Any]    ,       __lowerCamelCase    :				List[Any]=None    ,       **__lowerCamelCase    :				str ):
           super().__init__(features=__lowerCamelCase )
           snake_case__					:      Tuple  			=						np_array_kwargs





     def  _lowerCAmelCase			(    self    :				Optional[int]    ,       __lowerCamelCase    :				Any ):
           if isinstance(__lowerCamelCase    ,       __lowerCamelCase ):
                 if column and all(
                     isinstance(__lowerCamelCase    ,       np.ndarray ) and x.shape == column[0].shape and x.dtype == column[0].dtype for x in column ):
                       return np.stack(__lowerCamelCase )
                 else:
                       # don't use np.array(column, dtype=object)
                       # since it fails in certain cases
                       # see https://stackoverflow.com/q/51005699
                       snake_case__					:      Dict  			=						np.empty(len(__lowerCamelCase )    ,       dtype=__lowerCamelCase )
                       snake_case__					:      str  			=						column
                       return out
           return column





     def  _lowerCAmelCase			(    self    :				Union[str, Any]    ,       __lowerCamelCase    :				str ):
           if isinstance(__lowerCamelCase    ,       (str, bytes, type(__lowerCamelCase )) ):
                 return value
           elif isinstance(__lowerCamelCase    ,       (np.character, np.ndarray) ) and np.issubdtype(value.dtype    ,       np.character ):
                 return value
           elif isinstance(__lowerCamelCase    ,       np.number ):
                 return value

           snake_case__					:      List[str]  			=						{}

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

                 if isinstance(__lowerCamelCase    ,       PIL.Image.Image ):
                       return np.asarray(__lowerCamelCase    ,       **self.np_array_kwargs )

           return np.asarray(__lowerCamelCase    ,       **{**default_dtype, **self.np_array_kwargs} )





     def  _lowerCAmelCase			(    self    :				List[Any]    ,       __lowerCamelCase    :				Union[str, Any] ):
           # support for torch, tf, jax etc.
           if config.TORCH_AVAILABLE and "torch" in sys.modules:
                 import torch

                 if isinstance(__lowerCamelCase    ,       torch.Tensor ):
                       return self._tensorize(data_struct.detach().cpu().numpy()[()] )
           if hasattr(__lowerCamelCase    ,       '__array__' ) and not isinstance(__lowerCamelCase    ,       (np.ndarray, np.character, np.number) ):
                 snake_case__					:      Union[str, Any]  			=						data_struct.__array__()
           # support for nested types like struct of list of struct
           if isinstance(__lowerCamelCase    ,       np.ndarray ):
                 if data_struct.dtype == object:
                       return self._consolidate([self.recursive_tensorize(__lowerCamelCase ) for substruct in data_struct] )
           if isinstance(__lowerCamelCase    ,       (list, tuple) ):
                 return self._consolidate([self.recursive_tensorize(__lowerCamelCase ) for substruct in data_struct] )
           return self._tensorize(__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				Union[str, Any]    ,       __lowerCamelCase    :				dict ):
           return map_nested(self._recursive_tensorize    ,       __lowerCamelCase    ,       map_list=__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				Optional[Any]    ,       __lowerCamelCase    :				pa.Table ):
           snake_case__					:      Tuple  			=						self.numpy_arrow_extractor().extract_row(__lowerCamelCase )
           snake_case__					:      List[Any]  			=						self.python_features_decoder.decode_row(__lowerCamelCase )
           return self.recursive_tensorize(__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				Union[str, Any]    ,       __lowerCamelCase    :				pa.Table ):
           snake_case__					:      Any  			=						self.numpy_arrow_extractor().extract_column(__lowerCamelCase )
           snake_case__					:      Optional[Any]  			=						self.python_features_decoder.decode_column(__lowerCamelCase    ,       pa_table.column_names[0] )
           snake_case__					:      int  			=						self.recursive_tensorize(__lowerCamelCase )
           snake_case__					:      Optional[int]  			=						self._consolidate(__lowerCamelCase )
           return column





     def  _lowerCAmelCase			(    self    :				Optional[Any]    ,       __lowerCamelCase    :				pa.Table ):
           snake_case__					:      int  			=						self.numpy_arrow_extractor().extract_batch(__lowerCamelCase )
           snake_case__					:      Optional[Any]  			=						self.python_features_decoder.decode_batch(__lowerCamelCase )
           snake_case__					:      Union[str, Any]  			=						self.recursive_tensorize(__lowerCamelCase )
           for column_name in batch:
                 snake_case__					:      int  			=						self._consolidate(batch[column_name] )
           return batch






'''simple docstring'''






def 		UpperCamelCase__			(		__SCREAMING_SNAKE_CASE = 1000		)						->      int:
      snake_case__					:      List[str]  			=						0
      snake_case__					:      int  			=						(n - 1) // 3
      total += ((terms) * (6 + (terms - 1) * 3)) // 2  # total of an A.P.
      snake_case__					:      Optional[Any]  			=						(n - 1) // 5
      total += ((terms) * (10 + (terms - 1) * 5)) // 2
      snake_case__					:      Tuple  			=						(n - 1) // 15
      total -= ((terms) * (30 + (terms - 1) * 15)) // 2
      return total


if __name__ == "__main__":
      print(F'{solution() = }')
