



'''simple docstring'''





from cva import destroyAllWindows, imread, imshow, waitKey
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    lowerCAmelCase__      ,   lowerCAmelCase__ :  Union[str, Any]							      =					img.shape[0], img.shape[1]

    # converting each pixel's color to its negative
    for i in range(UpperCamelCase			):
        for j in range(UpperCamelCase			):
            lowerCAmelCase__ :  Union[str, Any]							      =					[255, 255, 255] - img[i][j]

    return img


if __name__ == "__main__":
 # read original image
 _lowerCAmelCase      						=	imread('''image_data/lena.jpg''', 1)

 # convert to its negative
 _lowerCAmelCase      						=	convert_to_negative(img)

 # show result image
 imshow('''negative of original image''', img)
 waitKey(0)
 destroyAllWindows()










"""simple docstring"""




import json
import os
from typing import Optional, Tuple

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


_snake_case          =   logging.get_logger(__name__)

_snake_case          =   {'vocab_file': 'vocab.json'}

_snake_case          =   {
    'vocab_file': {
        'mgp-str': 'https://huggingface.co/alibaba-damo/mgp-str-base/blob/main/vocab.json',
    }
}

_snake_case          =   {'mgp-str': 27}






class        UpperCamelCase			(	snake_case_      ):
 UpperCamelCase					:       List[str]			=					VOCAB_FILES_NAMES
 UpperCamelCase					:       Union[str, Any]			=					PRETRAINED_VOCAB_FILES_MAP
 UpperCamelCase					:       Optional[int]			=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES


 def __init__(     self		:						Optional[int]							,						UpperCAmelCase__		:						List[str]							,						UpperCAmelCase__		:						List[Any]="[GO]"							,						UpperCAmelCase__		:						Tuple="[GO]"							,						UpperCAmelCase__		:						Optional[int]="[s]"							,						UpperCAmelCase__		:						int="[GO]"							,						**UpperCAmelCase__		:						Dict							)					->       int:
   super().__init__(
       unk_token=UpperCAmelCase__							,						bos_token=UpperCAmelCase__							,						eos_token=UpperCAmelCase__							,						pad_token=UpperCAmelCase__							,						**UpperCAmelCase__							,						)

   with open(UpperCAmelCase__							,						encoding="""utf-8"""							) as vocab_handle:
     _a  :       int             =	json.load(UpperCAmelCase__							)
   _a  :       Optional[int]             =	{v: k for k, v in self.vocab.items()}


 @property
 def _lowercase	(     self		:						Dict							)					->       Union[str, Any]:
   return len(self.vocab							)


 def _lowercase	(     self		:						Union[str, Any]							)					->       str:
   return dict(self.vocab							,						**self.added_tokens_encoder							)


 def _lowercase	(     self		:						Dict							,						UpperCAmelCase__		:						str							)					->       Union[str, Any]:
   _a  :       Tuple             =	[]
   for s in text:
     char_tokens.extend(UpperCAmelCase__							)
   return char_tokens


 def _lowercase	(     self		:						List[Any]							,						UpperCAmelCase__		:						str							)					->       Dict:
   return self.vocab.get(UpperCAmelCase__							,						self.vocab.get(self.unk_token							)							)


 def _lowercase	(     self		:						Optional[int]							,						UpperCAmelCase__		:						Tuple							)					->       List[Any]:
   return self.decoder.get(UpperCAmelCase__							)







 def _lowercase	(     self		:						Optional[int]							,						UpperCAmelCase__		:						str							,						UpperCAmelCase__		:						Optional[str] = None							)					->       Tuple[str]:
   if not os.path.isdir(UpperCAmelCase__							):
     logger.error("""Vocabulary path ({}) should be a directory""".format(UpperCAmelCase__							)							)
     return
   _a  :       Tuple             =	os.path.join(
       UpperCAmelCase__							,						(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]							)

   with open(UpperCAmelCase__							,						"""w"""							,						encoding="""utf-8"""							) as f:
     f.write(json.dumps(self.vocab							,						indent=2							,						sort_keys=UpperCAmelCase__							,						ensure_ascii=UpperCAmelCase__							) + """\n"""							)

   return (vocab_file,)

