



"""simple docstring"""







import unicodedata
from dataclasses import dataclass
from typing import Optional, Union

import numpy as np

from transformers.data.data_collator import DataCollatorMixin
from transformers.file_utils import PaddingStrategy
from transformers.tokenization_utils_base import PreTrainedTokenizerBase

def       _lowerCamelCase				(							UpperCAmelCase_ :       Union[str, Any],	UpperCAmelCase_ :       str,	UpperCAmelCase_ :       List[Any],	UpperCAmelCase_ :       Any     )	-> Any:






	"""simple docstring"""





	if isinstance(UpperCAmelCase_,	UpperCAmelCase_     ):
		A__											=					np.full((len(UpperCAmelCase_     ), sequence_length, 2),	UpperCAmelCase_     )
	else:
		A__											=					np.full((len(UpperCAmelCase_     ), sequence_length),	UpperCAmelCase_     )

	for i, tensor in enumerate(UpperCAmelCase_     ):
		if padding_side == "right":
			if isinstance(UpperCAmelCase_,	UpperCAmelCase_     ):
				A__											=					tensor[:sequence_length]
			else:
				A__											=					tensor[:sequence_length]
		else:
			if isinstance(UpperCAmelCase_,	UpperCAmelCase_     ):
				A__											=					tensor[:sequence_length]
			else:
				A__											=					tensor[:sequence_length]

	return out_tensor.tolist()

def       _lowerCamelCase				(							UpperCAmelCase_ :       int     )	-> List[Any]:






	"""simple docstring"""





	A__											=					ord(UpperCAmelCase_     )
	if (cp >= 33 and cp <= 47) or (cp >= 58 and cp <= 64) or (cp >= 91 and cp <= 96) or (cp >= 123 and cp <= 126):
		return True
	A__											=					unicodedata.category(UpperCAmelCase_     )
	if cat.startswith("P"     ):
		return True
	return False






@dataclass
class       UpperCamelCase__			(   _lowerCAmelCase      ):

			"""simple docstring"""


			A__	:					PreTrainedTokenizerBase
			A__	:					Union[bool, str, PaddingStrategy]							  =     True
			A__	:					Optional[int]							  =     None
			A__	:					Optional[int]							  =     None
			A__	:					int							  =     -1_0_0
			A__	:					str							  =     "pt"


			def   snake_case__	(      self						,	SCREAMING_SNAKE_CASE__		)      ->	Optional[Any]:
				import torch

				A__											=					"label" if "label" in features[0].keys() else "labels"
				A__											=					[feature[label_name] for feature in features] if label_name in features[0].keys() else None
				A__											=					self.tokenizer.pad(
				    SCREAMING_SNAKE_CASE__						,	padding=self.padding						,	max_length=self.max_length						,	pad_to_multiple_of=self.pad_to_multiple_of						,	return_tensors="pt" if labels is None else None						,	)

				if labels is None:
					return batch

				A__											=					torch.tensor(batch["entity_ids"]		).shape[1]
				A__											=					self.tokenizer.padding_side
				if padding_side == "right":
					A__											=					[
					    list(SCREAMING_SNAKE_CASE__		) + [self.label_pad_token_id] * (sequence_length - len(SCREAMING_SNAKE_CASE__		)) for label in labels
					]
				else:
					A__											=					[
					    [self.label_pad_token_id] * (sequence_length - len(SCREAMING_SNAKE_CASE__		)) + list(SCREAMING_SNAKE_CASE__		) for label in labels
					]

				A__											=					[feature["ner_tags"] for feature in features]
				A__											=					padding_tensor(SCREAMING_SNAKE_CASE__						,	-1						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__		)
				A__											=					[feature["original_entity_spans"] for feature in features]
				A__											=					padding_tensor(SCREAMING_SNAKE_CASE__						,	(-1, -1)						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__		)
				A__											=					{k: torch.tensor(SCREAMING_SNAKE_CASE__						,	dtype=torch.intaa		) for k, v in batch.items()}

				return batch









"""simple docstring"""







def       _lowerCamelCase				(							UpperCAmelCase_ :       int     )	-> int:






	"""simple docstring"""





	assert (
	    isinstance(UpperCAmelCase_,	UpperCAmelCase_     ) and number_of_steps > 0
	), F"""number_of_steps needs to be positive integer, your input {number_of_steps}"""
	if number_of_steps == 1:
		return 1
	A__							,							A__											=					1, 1
	for _ in range(number_of_steps - 1     ):
		A__							,							A__											=					current + previous, current
	return current


if __name__ == "__main__":
			import doctest

			doctest.testmod()




