
from packaging import version

from .import_utils import is_accelerate_available


if is_accelerate_available():
     import accelerate


def 						UpperCAmelCase      (     a_						)		->     List[str]:







    """simple docstring"""



    if not is_accelerate_available():
        return method
    __A             =			version.parse(accelerate.__version__						).base_version
    if version.parse(a_						) < version.parse("0.17.0"						):
        return method

    def wrapper(self		,       *a_		,       **a_						):
        if hasattr(self		,       "_hf_hook"						) and hasattr(self._hf_hook		,       "pre_forward"						):
            self._hf_hook.pre_forward(self						)
        return method(self		,       *a_		,       **a_						)

    return wrapper


import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import ClassLabel, Features, Value
from .base import TaskTemplate





@dataclass(frozen=__SCREAMING_SNAKE_CASE  )
class 							UpperCAmelCase				(  __SCREAMING_SNAKE_CASE  ):




	'''simple docstring'''





	snake_case_    =					field(default="text-classification"      ,      metadata={"include_in_asdict_even_if_is_default": True}  )
	snake_case_    =					Features({"text": Value("string"  )}  )
	snake_case_    =					Features({"labels": ClassLabel}  )
	snake_case_    =					"text"
	snake_case_    =					"labels"






	def     UpperCamelCase_  (	self :			Optional[Any]							,A :			Dict			):
					if self.label_column not in features:
									raise ValueError(f'''Column {self.label_column} is not present in features.'''			)
					if not isinstance(features[self.label_column]							,A			):
									raise ValueError(f'''Column {self.label_column} is not a ClassLabel.'''			)
					__A             =			copy.deepcopy(self			)
					__A             =			self.label_schema.copy()
					__A             =			features[self.label_column]
					__A             =			label_schema
					return task_template







	@property
	def     UpperCamelCase_  (	self :			Dict			):
					return {
					    self.text_column: "text",
					    self.label_column: "labels",
					}
