
"""simple docstring"""




from typing import Dict

from .base import GenericTensor, Pipeline



class 	lowerCAmelCase_						(a__  ):


				"""simple docstring"""



				def 	__magic_name__    (self   ,       SCREAMING_SNAKE_CASE__=None   ,       SCREAMING_SNAKE_CASE__=None   ,       SCREAMING_SNAKE_CASE__=None   ,       **SCREAMING_SNAKE_CASE__    )					->		Any:



											"""simple docstring"""




											if tokenize_kwargs is None:
																		SCREAMING_SNAKE_CASE__						:       Optional[Any]           =   {}

											if truncation is not None:
																		if "truncation" in tokenize_kwargs:
																									raise ValueError(
																									    """truncation parameter defined twice (given as keyword argument as well as in tokenize_kwargs)"""    )
																		SCREAMING_SNAKE_CASE__						:       List[str]           =   truncation

											SCREAMING_SNAKE_CASE__						:       List[str]           =   tokenize_kwargs

											SCREAMING_SNAKE_CASE__						:       Any           =   {}
											if return_tensors is not None:
																		SCREAMING_SNAKE_CASE__						:       int           =   return_tensors

											return preprocess_params, {}, postprocess_params



				def 	__magic_name__    (self   ,       SCREAMING_SNAKE_CASE__   ,       **SCREAMING_SNAKE_CASE__    )					->		Dict[str, GenericTensor]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:       str           =   self.framework
											SCREAMING_SNAKE_CASE__						:       Tuple           =   self.tokenizer(SCREAMING_SNAKE_CASE__   ,       return_tensors=SCREAMING_SNAKE_CASE__   ,       **SCREAMING_SNAKE_CASE__    )
											return model_inputs



				def 	__magic_name__    (self   ,       SCREAMING_SNAKE_CASE__    )					->		Union[str, Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:       Tuple           =   self.model(**SCREAMING_SNAKE_CASE__    )
											return model_outputs



				def 	__magic_name__    (self   ,       SCREAMING_SNAKE_CASE__   ,       SCREAMING_SNAKE_CASE__=False    )					->		Optional[Any]:



											"""simple docstring"""




											if return_tensors:
																		return model_outputs[0]
											if self.framework == "pt":
																		return model_outputs[0].tolist()
											elif self.framework == "tf":
																		return model_outputs[0].numpy().tolist()



				def __call__(self   ,       *SCREAMING_SNAKE_CASE__   ,       **SCREAMING_SNAKE_CASE__    )					->		Any:



											"""simple docstring"""




											return super().__call__(*SCREAMING_SNAKE_CASE__   ,       **SCREAMING_SNAKE_CASE__    )








'''simple docstring'''

a_  :				Any						= """0.21.0"""

from .accelerator import Accelerator
from .big_modeling import (
    cpu_offload,
    cpu_offload_with_hook,
    disk_offload,
    dispatch_model,
    init_empty_weights,
    init_on_device,
    load_checkpoint_and_dispatch,
)
from .data_loader import skip_first_batches
from .launchers import debug_launcher, notebook_launcher
from .state import PartialState
from .utils import (
    DeepSpeedPlugin,
    DistributedDataParallelKwargs,
    DistributedType,
    FullyShardedDataParallelPlugin,
    GradScalerKwargs,
    InitProcessGroupKwargs,
    find_executable_batch_size,
    infer_auto_device_map,
    is_rich_available,
    load_checkpoint_in_model,
    synchronize_rng_states,
)


if is_rich_available():
     from .utils import rich



