




'''simple docstring'''




import json
import pathlib
import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision, slow
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
     import torch

if is_vision_available():
     from PIL import Image

     from transformers import DetaImageProcessor


class   __UpperCamelCase       ( unittest.TestCase				):






       def __init__(							self,		lowerCAmelCase,		lowerCAmelCase=7,		lowerCAmelCase=3,		lowerCAmelCase=30,		lowerCAmelCase=400,		lowerCAmelCase=True,		lowerCAmelCase=None,		lowerCAmelCase=True,		lowerCAmelCase=[0.5, 0.5, 0.5],		lowerCAmelCase=[0.5, 0.5, 0.5],		lowerCAmelCase=True,		lowerCAmelCase=1 / 255,		lowerCAmelCase=True,		):



              """simple docstring"""







              lowerCamelCase_							=size if size is not None else {'''shortest_edge''': 18, '''longest_edge''': 1_333}
              lowerCamelCase_							=parent
              lowerCamelCase_							=batch_size
              lowerCamelCase_							=num_channels
              lowerCamelCase_							=min_resolution
              lowerCamelCase_							=max_resolution
              lowerCamelCase_							=do_resize
              lowerCamelCase_							=size
              lowerCamelCase_							=do_normalize
              lowerCamelCase_							=image_mean
              lowerCamelCase_							=image_std
              lowerCamelCase_							=do_rescale
              lowerCamelCase_							=rescale_factor
              lowerCamelCase_							=do_pad






       def      lowercase__     (							self  ):



              """simple docstring"""







              return {
                  "do_resize": self.do_resize,
                  "size": self.size,
                  "do_normalize": self.do_normalize,
                  "image_mean": self.image_mean,
                  "image_std": self.image_std,
                  "do_rescale": self.do_rescale,
                  "rescale_factor": self.rescale_factor,
                  "do_pad": self.do_pad,
              }






       def      lowercase__     (							self,		lowerCAmelCase,		lowerCAmelCase=False  ):



              """simple docstring"""







              if not batched:
                     lowerCamelCase_							=image_inputs[0]
                     if isinstance(lowerCAmelCase,		Image.Image  ):
                            lowerCamelCase_,      lowerCamelCase_							=image.size
                     else:
                            lowerCamelCase_,      lowerCamelCase_							=image.shape[1], image.shape[2]
                     if w < h:
                            lowerCamelCase_							=int(self.size['''shortest_edge'''] * h / w  )
                            lowerCamelCase_							=self.size['''shortest_edge''']
                     elif w > h:
                            lowerCamelCase_							=self.size['''shortest_edge''']
                            lowerCamelCase_							=int(self.size['''shortest_edge'''] * w / h  )
                     else:
                            lowerCamelCase_							=self.size['''shortest_edge''']
                            lowerCamelCase_							=self.size['''shortest_edge''']

              else:
                     lowerCamelCase_							=[]
                     for image in image_inputs:
                            lowerCamelCase_,      lowerCamelCase_							=self.get_expected_values([image]  )
                            expected_values.append((expected_height, expected_width)  )
                     lowerCamelCase_							=max(lowerCAmelCase,		key=lambda lowerCAmelCase  : item[0]  )[0]
                     lowerCamelCase_							=max(lowerCAmelCase,		key=lambda lowerCAmelCase  : item[1]  )[1]

              return expected_height, expected_width





@require_torch
@require_vision
class   __UpperCamelCase       ( lowerCamelCase__			,					unittest.TestCase				):
       lowercase	:    List[str]      						=DetaImageProcessor if is_vision_available() else None






       def      lowercase__     (							self  ):



              """simple docstring"""







              lowerCamelCase_							=DetaImageProcessingTester(self  )






       @property
       def      lowercase__     (							self  ):



              """simple docstring"""







              return self.image_processor_tester.prepare_image_processor_dict()






       def      lowercase__     (							self  ):



              """simple docstring"""







              lowerCamelCase_							=self.image_processing_class(**self.image_processor_dict  )
              self.assertTrue(hasattr(lowerCAmelCase,		'''image_mean'''  )  )
              self.assertTrue(hasattr(lowerCAmelCase,		'''image_std'''  )  )
              self.assertTrue(hasattr(lowerCAmelCase,		'''do_normalize'''  )  )
              self.assertTrue(hasattr(lowerCAmelCase,		'''do_resize'''  )  )
              self.assertTrue(hasattr(lowerCAmelCase,		'''do_rescale'''  )  )
              self.assertTrue(hasattr(lowerCAmelCase,		'''do_pad'''  )  )
              self.assertTrue(hasattr(lowerCAmelCase,		'''size'''  )  )






       def      lowercase__     (							self  ):



              """simple docstring"""







              lowerCamelCase_							=self.image_processing_class.from_dict(self.image_processor_dict  )
              self.assertEqual(image_processor.size,		{'''shortest_edge''': 18, '''longest_edge''': 1_333}  )
              self.assertEqual(image_processor.do_pad,		lowerCAmelCase  )






       def      lowercase__     (							self  ):



              """simple docstring"""







              pass






       def      lowercase__     (							self  ):



              """simple docstring"""







              lowerCamelCase_							=self.image_processing_class(**self.image_processor_dict  )
              # create random PIL images
              lowerCamelCase_							=prepare_image_inputs(self.image_processor_tester,		equal_resolution=lowerCAmelCase  )
              for image in image_inputs:
                     self.assertIsInstance(lowerCAmelCase,		Image.Image  )

              # Test not batched input
              lowerCamelCase_							=image_processing(image_inputs[0],		return_tensors='''pt'''  ).pixel_values

              lowerCamelCase_,      lowerCamelCase_							=self.image_processor_tester.get_expected_values(lowerCAmelCase  )

              self.assertEqual(
                  encoded_images.shape,		(1, self.image_processor_tester.num_channels, expected_height, expected_width),		)

              # Test batched
              lowerCamelCase_,      lowerCamelCase_							=self.image_processor_tester.get_expected_values(lowerCAmelCase,		batched=lowerCAmelCase  )

              lowerCamelCase_							=image_processing(lowerCAmelCase,		return_tensors='''pt'''  ).pixel_values
              self.assertEqual(
                  encoded_images.shape,		(
                      self.image_processor_tester.batch_size,
                      self.image_processor_tester.num_channels,
                      expected_height,
                      expected_width,
                  ),		)






       def      lowercase__     (							self  ):



              """simple docstring"""







              lowerCamelCase_							=self.image_processing_class(**self.image_processor_dict  )
              # create random numpy tensors
              lowerCamelCase_							=prepare_image_inputs(self.image_processor_tester,		equal_resolution=lowerCAmelCase,		numpify=lowerCAmelCase  )
              for image in image_inputs:
                     self.assertIsInstance(lowerCAmelCase,		np.ndarray  )

              # Test not batched input
              lowerCamelCase_							=image_processing(image_inputs[0],		return_tensors='''pt'''  ).pixel_values

              lowerCamelCase_,      lowerCamelCase_							=self.image_processor_tester.get_expected_values(lowerCAmelCase  )

              self.assertEqual(
                  encoded_images.shape,		(1, self.image_processor_tester.num_channels, expected_height, expected_width),		)

              # Test batched
              lowerCamelCase_							=image_processing(lowerCAmelCase,		return_tensors='''pt'''  ).pixel_values

              lowerCamelCase_,      lowerCamelCase_							=self.image_processor_tester.get_expected_values(lowerCAmelCase,		batched=lowerCAmelCase  )

              self.assertEqual(
                  encoded_images.shape,		(
                      self.image_processor_tester.batch_size,
                      self.image_processor_tester.num_channels,
                      expected_height,
                      expected_width,
                  ),		)






       def      lowercase__     (							self  ):



              """simple docstring"""







              lowerCamelCase_							=self.image_processing_class(**self.image_processor_dict  )
              # create random PyTorch tensors
              lowerCamelCase_							=prepare_image_inputs(self.image_processor_tester,		equal_resolution=lowerCAmelCase,		torchify=lowerCAmelCase  )
              for image in image_inputs:
                     self.assertIsInstance(lowerCAmelCase,		torch.Tensor  )

              # Test not batched input
              lowerCamelCase_							=image_processing(image_inputs[0],		return_tensors='''pt'''  ).pixel_values

              lowerCamelCase_,      lowerCamelCase_							=self.image_processor_tester.get_expected_values(lowerCAmelCase  )

              self.assertEqual(
                  encoded_images.shape,		(1, self.image_processor_tester.num_channels, expected_height, expected_width),		)

              # Test batched
              lowerCamelCase_							=image_processing(lowerCAmelCase,		return_tensors='''pt'''  ).pixel_values

              lowerCamelCase_,      lowerCamelCase_							=self.image_processor_tester.get_expected_values(lowerCAmelCase,		batched=lowerCAmelCase  )

              self.assertEqual(
                  encoded_images.shape,		(
                      self.image_processor_tester.batch_size,
                      self.image_processor_tester.num_channels,
                      expected_height,
                      expected_width,
                  ),		)






       @slow
       def      lowercase__     (							self  ):



              """simple docstring"""







              lowerCamelCase_							=Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''  )
              with open('''./tests/fixtures/tests_samples/COCO/coco_annotations.txt''',		'''r'''  ) as f:
                     lowerCamelCase_							=json.loads(f.read()  )

              lowerCamelCase_							={'''image_id''': 39_769, '''annotations''': target}

              # encode them
              lowerCamelCase_							=DetaImageProcessor()
              lowerCamelCase_							=image_processing(images=lowerCAmelCase,		annotations=lowerCAmelCase,		return_tensors='''pt'''  )

              # verify pixel values
              lowerCamelCase_							=torch.Size([1, 3, 800, 1_066]  )
              self.assertEqual(encoding['''pixel_values'''].shape,		lowerCAmelCase  )

              lowerCamelCase_							=torch.tensor([0.2_7_9_6, 0.3_1_3_8, 0.3_4_8_1]  )
              self.assertTrue(torch.allclose(encoding['''pixel_values'''][0, 0, 0, :3],		lowerCAmelCase,		atol=1e-4  )  )

              # verify area
              lowerCamelCase_							=torch.tensor([5_8_8_7.9_6_0_0, 1_1_2_5_0.2_0_6_1, 4_8_9_3_5_3.8_4_3_8, 8_3_7_1_2_2.7_5_0_0, 1_4_7_9_6_7.5_1_5_6, 1_6_5_7_3_2.3_4_3_8]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''area'''],		lowerCAmelCase  )  )
              # verify boxes
              lowerCamelCase_							=torch.Size([6, 4]  )
              self.assertEqual(encoding['''labels'''][0]['''boxes'''].shape,		lowerCAmelCase  )
              lowerCamelCase_							=torch.tensor([0.5_5_0_3, 0.2_7_6_5, 0.0_6_0_4, 0.2_2_1_5]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''boxes'''][0],		lowerCAmelCase,		atol=1e-3  )  )
              # verify image_id
              lowerCamelCase_							=torch.tensor([39_769]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''image_id'''],		lowerCAmelCase  )  )
              # verify is_crowd
              lowerCamelCase_							=torch.tensor([0, 0, 0, 0, 0, 0]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''iscrowd'''],		lowerCAmelCase  )  )
              # verify class_labels
              lowerCamelCase_							=torch.tensor([75, 75, 63, 65, 17, 17]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''class_labels'''],		lowerCAmelCase  )  )
              # verify orig_size
              lowerCamelCase_							=torch.tensor([480, 640]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''orig_size'''],		lowerCAmelCase  )  )
              # verify size
              lowerCamelCase_							=torch.tensor([800, 1_066]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''size'''],		lowerCAmelCase  )  )






       @slow
       def      lowercase__     (							self  ):



              """simple docstring"""







              lowerCamelCase_							=Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''  )
              with open('''./tests/fixtures/tests_samples/COCO/coco_panoptic_annotations.txt''',		'''r'''  ) as f:
                     lowerCamelCase_							=json.loads(f.read()  )

              lowerCamelCase_							={'''file_name''': '''000000039769.png''', '''image_id''': 39_769, '''segments_info''': target}

              lowerCamelCase_							=pathlib.Path('''./tests/fixtures/tests_samples/COCO/coco_panoptic'''  )

              # encode them
              lowerCamelCase_							=DetaImageProcessor(format='''coco_panoptic'''  )
              lowerCamelCase_							=image_processing(images=lowerCAmelCase,		annotations=lowerCAmelCase,		masks_path=lowerCAmelCase,		return_tensors='''pt'''  )

              # verify pixel values
              lowerCamelCase_							=torch.Size([1, 3, 800, 1_066]  )
              self.assertEqual(encoding['''pixel_values'''].shape,		lowerCAmelCase  )

              lowerCamelCase_							=torch.tensor([0.2_7_9_6, 0.3_1_3_8, 0.3_4_8_1]  )
              self.assertTrue(torch.allclose(encoding['''pixel_values'''][0, 0, 0, :3],		lowerCAmelCase,		atol=1e-4  )  )

              # verify area
              lowerCamelCase_							=torch.tensor([1_4_7_9_7_9.6_8_7_5, 1_6_5_5_2_7.0_4_6_9, 4_8_4_6_3_8.5_9_3_8, 1_1_2_9_2.9_3_7_5, 5_8_7_9.6_5_6_2, 7_6_3_4.1_1_4_7]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''area'''],		lowerCAmelCase  )  )
              # verify boxes
              lowerCamelCase_							=torch.Size([6, 4]  )
              self.assertEqual(encoding['''labels'''][0]['''boxes'''].shape,		lowerCAmelCase  )
              lowerCamelCase_							=torch.tensor([0.2_6_2_5, 0.5_4_3_7, 0.4_6_8_8, 0.8_6_2_5]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''boxes'''][0],		lowerCAmelCase,		atol=1e-3  )  )
              # verify image_id
              lowerCamelCase_							=torch.tensor([39_769]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''image_id'''],		lowerCAmelCase  )  )
              # verify is_crowd
              lowerCamelCase_							=torch.tensor([0, 0, 0, 0, 0, 0]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''iscrowd'''],		lowerCAmelCase  )  )
              # verify class_labels
              lowerCamelCase_							=torch.tensor([17, 17, 63, 75, 75, 93]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''class_labels'''],		lowerCAmelCase  )  )
              # verify masks
              lowerCamelCase_							=822_873
              self.assertEqual(encoding['''labels'''][0]['''masks'''].sum().item(),		lowerCAmelCase  )
              # verify orig_size
              lowerCamelCase_							=torch.tensor([480, 640]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''orig_size'''],		lowerCAmelCase  )  )
              # verify size
              lowerCamelCase_							=torch.tensor([800, 1_066]  )
              self.assertTrue(torch.allclose(encoding['''labels'''][0]['''size'''],		lowerCAmelCase  )  )









"""simple docstring"""
import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


_lowerCAmelCase    :Optional[int]     =					logging.get_logger(__name__)

_lowerCAmelCase    :List[str]     =					'▁'

_lowerCAmelCase    :Tuple     =					{'vocab_file': 'sentencepiece.bpe.model'}

_lowerCAmelCase    :List[Any]     =					{
    'vocab_file': {
        'xlm-roberta-base': 'https://huggingface.co/xlm-roberta-base/resolve/main/sentencepiece.bpe.model',
        'xlm-roberta-large': 'https://huggingface.co/xlm-roberta-large/resolve/main/sentencepiece.bpe.model',
        'xlm-roberta-large-finetuned-conll02-dutch': (
            'https://huggingface.co/xlm-roberta-large-finetuned-conll02-dutch/resolve/main/sentencepiece.bpe.model'
        ),
        'xlm-roberta-large-finetuned-conll02-spanish': (
            'https://huggingface.co/xlm-roberta-large-finetuned-conll02-spanish/resolve/main/sentencepiece.bpe.model'
        ),
        'xlm-roberta-large-finetuned-conll03-english': (
            'https://huggingface.co/xlm-roberta-large-finetuned-conll03-english/resolve/main/sentencepiece.bpe.model'
        ),
        'xlm-roberta-large-finetuned-conll03-german': (
            'https://huggingface.co/xlm-roberta-large-finetuned-conll03-german/resolve/main/sentencepiece.bpe.model'
        ),
    }
}

_lowerCAmelCase    :Tuple     =					{
    'xlm-roberta-base': 512,
    'xlm-roberta-large': 512,
    'xlm-roberta-large-finetuned-conll02-dutch': 512,
    'xlm-roberta-large-finetuned-conll02-spanish': 512,
    'xlm-roberta-large-finetuned-conll03-english': 512,
    'xlm-roberta-large-finetuned-conll03-german': 512,
}
class 							_UpperCAmelCase							( a      ):





     '''simple docstring'''



     a__									=VOCAB_FILES_NAMES
     a__									=PRETRAINED_VOCAB_FILES_MAP
     a__									=PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     a__									=['''input_ids''', '''attention_mask''']





     def __init__(					self       ,	A       ,	A="<s>"       ,	A="</s>"       ,	A="</s>"       ,	A="<s>"       ,	A="<unk>"       ,	A="<pad>"       ,	A="<mask>"       ,	A = None       ,	**A       ,	)							->					None:
         # Mask token behave like a normal word, i.e. include the space before it
         _UpperCAmelCase							:  Tuple											=    AddedToken(A       ,	lstrip=A       ,	rstrip=A		) if isinstance(A       ,	A		) else mask_token

         _UpperCAmelCase							:  List[Any]											=    {} if sp_model_kwargs is None else sp_model_kwargs

         super().__init__(
             bos_token=A       ,	eos_token=A       ,	unk_token=A       ,	sep_token=A       ,	cls_token=A       ,	pad_token=A       ,	mask_token=A       ,	sp_model_kwargs=self.sp_model_kwargs       ,	**A       ,	)

         _UpperCAmelCase							:  Any											=    spm.SentencePieceProcessor(**self.sp_model_kwargs		)
         self.sp_model.Load(str(A		)		)
         _UpperCAmelCase							:  List[Any]											=    vocab_file

         # Original fairseq vocab and spm vocab must be "aligned":
         # Vocab    |    0    |    1    |   2    |    3    |  4  |  5  |  6  |   7   |   8   |  9
         # -------- | ------- | ------- | ------ | ------- | --- | --- | --- | ----- | ----- | ----
         # fairseq  | '<s>'   | '<pad>' | '</s>' | '<unk>' | ',' | '.' | '▁' | 's'   | '▁de' | '-'
         # spm      | '<unk>' | '<s>'   | '</s>' | ','     | '.' | '▁' | 's' | '▁de' | '-'   | '▁a'

         # Mimic fairseq token-to-id alignment for the first 4 token
         _UpperCAmelCase							:  List[str]											=    {'''<s>''': 0, '''<pad>''': 1, '''</s>''': 2, '''<unk>''': 3}

         # The first "real" token "," has position 4 in the original fairseq vocab and position 3 in the spm vocab
         _UpperCAmelCase							:  Any											=    1

         _UpperCAmelCase							:  Optional[Any]											=    len(self.sp_model		) + self.fairseq_offset
         _UpperCAmelCase							:  int											=    {v: k for k, v in self.fairseq_tokens_to_ids.items()}





     def __getstate__(					self		)							->					Union[str, Any]:
         _UpperCAmelCase							:  Tuple											=    self.__dict__.copy()
         _UpperCAmelCase							:  List[str]											=    None
         _UpperCAmelCase							:  str											=    self.sp_model.serialized_model_proto()
         return state





     def __setstate__(					self       ,	A		)							->					Optional[int]:
         _UpperCAmelCase							:  Optional[int]											=    d

         # for backward compatibility
         if not hasattr(self       ,	'''sp_model_kwargs'''		):
             _UpperCAmelCase							:  Optional[Any]											=    {}

         _UpperCAmelCase							:  Optional[int]											=    spm.SentencePieceProcessor(**self.sp_model_kwargs		)
         self.sp_model.LoadFromSerializedProto(self.sp_model_proto		)





     def  __lowerCAmelCase	(					self       ,	A       ,	A = None		)							->					List[int]:

         if token_ids_a is None:
             return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
         _UpperCAmelCase							:  Any											=    [self.cls_token_id]
         _UpperCAmelCase							:  Any											=    [self.sep_token_id]
         return cls + token_ids_a + sep + sep + token_ids_a + sep





     def  __lowerCAmelCase	(					self       ,	A       ,	A = None       ,	A = False		)							->					List[int]:

         if already_has_special_tokens:
             return super().get_special_tokens_mask(
                 token_ids_a=A       ,	token_ids_a=A       ,	already_has_special_tokens=A		)

         if token_ids_a is None:
             return [1] + ([0] * len(A		)) + [1]
         return [1] + ([0] * len(A		)) + [1, 1] + ([0] * len(A		)) + [1]





     def  __lowerCAmelCase	(					self       ,	A       ,	A = None		)							->					List[int]:
         _UpperCAmelCase							:  Dict											=    [self.sep_token_id]
         _UpperCAmelCase							:  List[str]											=    [self.cls_token_id]

         if token_ids_a is None:
             return len(cls + token_ids_a + sep		) * [0]
         return len(cls + token_ids_a + sep + sep + token_ids_a + sep		) * [0]





     @property
     def  __lowerCAmelCase	(					self		)							->					Dict:
         return len(self.sp_model		) + self.fairseq_offset + 1  # Add the <mask> token





     def  __lowerCAmelCase	(					self		)							->					Tuple:
         _UpperCAmelCase							:  Dict											=    {self.convert_ids_to_tokens(A		): i for i in range(self.vocab_size		)}
         vocab.update(self.added_tokens_encoder		)
         return vocab





     def  __lowerCAmelCase	(					self       ,	A		)							->					List[str]:
         return self.sp_model.encode(A       ,	out_type=A		)





     def  __lowerCAmelCase	(					self       ,	A		)							->					Any:
         if token in self.fairseq_tokens_to_ids:
             return self.fairseq_tokens_to_ids[token]
         _UpperCAmelCase							:  Any											=    self.sp_model.PieceToId(A		)

         # Need to return unknown token if the SP model returned 0
         return spm_id + self.fairseq_offset if spm_id else self.unk_token_id





     def  __lowerCAmelCase	(					self       ,	A		)							->					int:
         if index in self.fairseq_ids_to_tokens:
             return self.fairseq_ids_to_tokens[index]
         return self.sp_model.IdToPiece(index - self.fairseq_offset		)





     def  __lowerCAmelCase	(					self       ,	A		)							->					int:
         _UpperCAmelCase							:  str											=    ''''''.join(A		).replace(A       ,	''' '''		).strip()
         return out_string





     def  __lowerCAmelCase	(					self       ,	A       ,	A = None		)							->					Tuple[str]:
         if not os.path.isdir(A		):
             logger.error(f'Vocabulary path ({save_directory}) should be a directory'		)
             return
         _UpperCAmelCase							:  List[Any]											=    os.path.join(
             A       ,	(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']		)

         if os.path.abspath(self.vocab_file		) != os.path.abspath(A		) and os.path.isfile(self.vocab_file		):
             copyfile(self.vocab_file       ,	A		)
         elif not os.path.isfile(self.vocab_file		):
             with open(A       ,	'''wb'''		) as fi:
                 _UpperCAmelCase							:  str											=    self.sp_model.serialized_model_proto()
                 fi.write(A		)

         return (out_vocab_file,)


