

'''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       UpperCAmelCase__    (      UpperCAmelCase__,       UpperCAmelCase__,       UpperCAmelCase__,       UpperCAmelCase__				)			->			Dict:
       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       UpperCAmelCase__    (      UpperCAmelCase__				)			->			Optional[Any]:
       A_						=      ord(UpperCAmelCase__				)
       if (cp >= 33 and cp <= 47) or (cp >= 58 and cp <= 64) or (cp >= 91 and cp <= 96) or (cp >= 1_23 and cp <= 1_26):
              return True
       A_						=      unicodedata.category(UpperCAmelCase__				)
       if cat.startswith("""P"""				):
              return True
       return False







@dataclass
class 					A__      (      _snake_case			):
    lowercase						=		42
    lowercase						=		True
    lowercase						=		None
    lowercase						=		None
    lowercase						=		-100
    lowercase						=		"pt"



    def 					snake_case_			(					self		,				UpperCamelCase__       )						->      Any:





           '''simple docstring'''
           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(
               UpperCamelCase__		,				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(UpperCamelCase__       ) + [self.label_pad_token_id] * (sequence_length - len(UpperCamelCase__       )) for label in labels
                  ]
           else:
                  A_						=      [
                      [self.label_pad_token_id] * (sequence_length - len(UpperCamelCase__       )) + list(UpperCamelCase__       ) for label in labels
                  ]

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

           return batch



'''simple docstring'''







__lowerCamelCase		       =    range(2, 20 + 1)
__lowerCamelCase		       =    [10**k for k in range(ks[-1] + 1)]
__lowerCamelCase		       =    {}
def       UpperCAmelCase__    (      UpperCAmelCase__,       UpperCAmelCase__,       UpperCAmelCase__,       UpperCAmelCase__				)			->			Tuple:
       A_						=      sum(a_i[j] for j in range(UpperCAmelCase__,       len(UpperCAmelCase__				)				)				)
       A_						=      sum(a_i[j] * base[j] for j in range(min(len(UpperCAmelCase__				),       UpperCAmelCase__				)				)				)

       A_					,			A_						=      0, 0
       A_						=      n - i

       A_						=      memo.get(UpperCAmelCase__				)

       if sub_memo is not None:
              A_						=      sub_memo.get(UpperCAmelCase__				)

              if jumps is not None and len(UpperCAmelCase__				) > 0:
                     # find and make the largest jump without going over
                     A_						=      -1
                     for _k in range(len(UpperCAmelCase__				) - 1,       -1,       -1				):
                            if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
                                   A_						=      _k
                                   break

                     if max_jump >= 0:
                            A_					,			A_					,			A_						=      jumps[max_jump]
                            # since the difference between jumps is cached, add c
                            A_						=      diff + c
                            for j in range(min(UpperCAmelCase__,       len(UpperCAmelCase__				)				)				):
                                   A_					,			A_						=      divmod(UpperCAmelCase__,       10				)
                            if new_c > 0:
                                   add(UpperCAmelCase__,       UpperCAmelCase__,       UpperCAmelCase__				)

              else:
                     A_						=      []
       else:
              A_						=      {c: []}
              A_						=      sub_memo

       if dn >= max_dn or c + diff >= base[k]:
              return diff, dn

       if k > ks[0]:
              while True:
                     # keep doing smaller jumps
                     A_					,			A_						=      next_term(UpperCAmelCase__,       k - 1,       i + dn,       UpperCAmelCase__				)
                     diff += _diff
                     dn += terms_jumped

                     if dn >= max_dn or c + diff >= base[k]:
                            break
       else:
              # would be too small a jump, just compute sequential terms instead
              A_					,			A_						=      compute(UpperCAmelCase__,       UpperCAmelCase__,       i + dn,       UpperCAmelCase__				)
              diff += _diff
              dn += terms_jumped

       A_						=      sub_memo[c]

       # keep jumps sorted by # of terms skipped
       A_						=      0
       while j < len(UpperCAmelCase__				):
              if jumps[j][1] > dn:
                     break
              j += 1

       # cache the jump for this value digitsum(b) and c
       sub_memo[c].insert(UpperCAmelCase__,       (diff, dn, k)				)
       return (diff, dn)
def       UpperCAmelCase__    (      UpperCAmelCase__,       UpperCAmelCase__,       UpperCAmelCase__,       UpperCAmelCase__				)			->			int:
       if i >= n:
              return 0, i
       if k > len(UpperCAmelCase__				):
              a_i.extend([0 for _ in range(k - len(UpperCAmelCase__				)				)]				)

       # note: a_i -> b * 10^k + c
       # ds_b -> digitsum(b)
       # ds_c -> digitsum(c)
       A_						=      i
       A_					,			A_					,			A_						=      0, 0, 0
       for j in range(len(UpperCAmelCase__				)				):
              if j >= k:
                     ds_b += a_i[j]
              else:
                     ds_c += a_i[j]

       while i < n:
              i += 1
              A_						=      ds_c + ds_b
              diff += addend
              A_						=      0
              for j in range(UpperCAmelCase__				):
                     A_						=      a_i[j] + addend
                     A_					,			A_						=      divmod(UpperCAmelCase__,       10				)

                     ds_c += a_i[j]

              if addend > 0:
                     break

       if addend > 0:
              add(UpperCAmelCase__,       UpperCAmelCase__,       UpperCAmelCase__				)
       return diff, i - start_i
def       UpperCAmelCase__    (      UpperCAmelCase__,       UpperCAmelCase__,       UpperCAmelCase__				)			->			str:
       for j in range(UpperCAmelCase__,       len(UpperCAmelCase__				)				):
              A_						=      digits[j] + addend
              if s >= 10:
                     A_					,			A_						=      divmod(UpperCAmelCase__,       10				)
                     A_						=      addend // 10 + quotient
              else:
                     A_						=      s
                     A_						=      addend // 10

              if addend == 0:
                     break

       while addend > 0:
              A_					,			A_						=      divmod(UpperCAmelCase__,       10				)
              digits.append(UpperCAmelCase__				)
def       UpperCAmelCase__    (      UpperCAmelCase__ = 10**15				)			->			int:
       A_						=      [1]
       A_						=      1
       A_						=      0
       while True:
              A_					,			A_						=      next_term(UpperCAmelCase__,       20,       i + dn,       UpperCAmelCase__				)
              dn += terms_jumped
              if dn == n - i:
                     break

       A_						=      0
       for j in range(len(UpperCAmelCase__				)				):
              a_n += digits[j] * 10**j
       return a_n


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