
from __future__ import annotations




def        __UpperCamelCase					(    lowerCAmelCase__							:    list[list[int]]  ):
 __a			:  List[Any]		    =  len(lowerCAmelCase__  )
 # We need to create solution object to save path.
 __a			:  str		    =  [[0 for _ in range(lowerCAmelCase__  )] for _ in range(lowerCAmelCase__  )]
 __a			:  Tuple		    =  run_maze(lowerCAmelCase__  ,       0  ,       0  ,       lowerCAmelCase__  )
 if solved:
  print('''\n'''.join(str(lowerCAmelCase__  ) for row in solutions  )  )
 else:
  print('''No solution exists!'''  )
 return solved




def        __UpperCamelCase					(    lowerCAmelCase__							:    list[list[int]]  ,       lowerCAmelCase__							:    int  ,       lowerCAmelCase__							:    int  ,       lowerCAmelCase__							:    list[list[int]]  ):
 __a			:  str		    =  len(lowerCAmelCase__  )
 # Final check point.
 if i == j == (size - 1):
  __a			:  int		    =  1
  return True

 __a			:  Tuple		    =  (not i < 0) and (not j < 0)  # Check lower bounds
 __a			:  Union[str, Any]		    =  (i < size) and (j < size)  # Check upper bounds

 if lower_flag and upper_flag:
  # check for already visited and block points.
  __a			:  List[str]		    =  (not solutions[i][j]) and (not maze[i][j])
  if block_flag:
   # check visited
   __a			:  Optional[Any]		    =  1

   # check for directions
   if (
       run_maze(lowerCAmelCase__  ,       i + 1  ,       lowerCAmelCase__  ,       lowerCAmelCase__  )
       or run_maze(lowerCAmelCase__  ,       lowerCAmelCase__  ,       j + 1  ,       lowerCAmelCase__  )
       or run_maze(lowerCAmelCase__  ,       i - 1  ,       lowerCAmelCase__  ,       lowerCAmelCase__  )
       or run_maze(lowerCAmelCase__  ,       lowerCAmelCase__  ,       j - 1  ,       lowerCAmelCase__  )
   ):
    return True

   __a			:  Any		    =  0
   return False
 return False


if __name__ == "__main__":
      import doctest

      doctest.testmod()


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					(    lowerCAmelCase__							:    Union[str, Any]  ,       lowerCAmelCase__							:    int  ,       lowerCAmelCase__							:    List[str]  ,       lowerCAmelCase__							:    Any  ):
 if isinstance(lowerCAmelCase__  ,       lowerCAmelCase__  ):
  __a			:  Union[str, Any]		    =  np.full((len(lowerCAmelCase__  ), sequence_length, 2)  ,       lowerCAmelCase__  )
 else:
  __a			:  str		    =  np.full((len(lowerCAmelCase__  ), sequence_length)  ,       lowerCAmelCase__  )

 for i, tensor in enumerate(lowerCAmelCase__  ):
  if padding_side == "right":
   if isinstance(lowerCAmelCase__  ,       lowerCAmelCase__  ):
    __a			:  Any		    =  tensor[:sequence_length]
   else:
    __a			:  List[Any]		    =  tensor[:sequence_length]
  else:
   if isinstance(lowerCAmelCase__  ,       lowerCAmelCase__  ):
    __a			:  Dict		    =  tensor[:sequence_length]
   else:
    __a			:  int		    =  tensor[:sequence_length]

 return out_tensor.tolist()




def        __UpperCamelCase					(    lowerCAmelCase__							:    Optional[Any]  ):
 __a			:  str		    =  ord(lowerCAmelCase__  )
 if (cp >= 3_3 and cp <= 4_7) or (cp >= 5_8 and cp <= 6_4) or (cp >= 9_1 and cp <= 9_6) or (cp >= 1_2_3 and cp <= 1_2_6):
  return True
 __a			:  List[str]		    =  unicodedata.category(lowerCAmelCase__  )
 if cat.startswith('''P'''  ):
  return True
 return False



@dataclass
class 		UpperCamelCase__  (	__lowercase   ):
   _SCREAMING_SNAKE_CASE				:							PreTrainedTokenizerBase
   _SCREAMING_SNAKE_CASE				:							Union[bool, str, PaddingStrategy]     	=				True
   _SCREAMING_SNAKE_CASE				:							Optional[int]     	=				None
   _SCREAMING_SNAKE_CASE				:							Optional[int]     	=				None
   _SCREAMING_SNAKE_CASE				:							int     	=				-100
   _SCREAMING_SNAKE_CASE				:							str     	=				"pt"
   def 				lowerCAmelCase      (self			: str ,    snake_case_			: Tuple       ):
    import torch

    __a			:  Union[str, Any]		    =  '''label''' if '''label''' in features[0].keys() else '''labels'''
    __a			:  Tuple		    =  [feature[label_name] for feature in features] if label_name in features[0].keys() else None
    __a			:  Union[str, Any]		    =  self.tokenizer.pad(
        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			:  List[str]		    =  torch.tensor(batch['''entity_ids''']       ).shape[1]
    __a			:  Tuple		    =  self.tokenizer.padding_side
    if padding_side == "right":
     __a			:  Union[str, Any]		    =  [
         list(snake_case_       ) + [self.label_pad_token_id] * (sequence_length - len(snake_case_       )) for label in labels
     ]
    else:
     __a			:  Dict		    =  [
         [self.label_pad_token_id] * (sequence_length - len(snake_case_       )) + list(snake_case_       ) for label in labels
     ]

    __a			:  Dict		    =  [feature['''ner_tags'''] for feature in features]
    __a			:  Optional[Any]		    =  padding_tensor(snake_case_ ,    -1 ,    snake_case_ ,    snake_case_       )
    __a			:  Union[str, Any]		    =  [feature['''original_entity_spans'''] for feature in features]
    __a			:  Optional[int]		    =  padding_tensor(snake_case_ ,    (-1, -1) ,    snake_case_ ,    snake_case_       )
    __a			:  List[str]		    =  {k: torch.tensor(snake_case_ ,    dtype=torch.intaa       ) for k, v in batch.items()}

    return batch
