"""simple docstring"""



import collections
import inspect
import unittest

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

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
   import torch
   from torch import nn

   from transformers import (
       FocalNetBackbone,
       FocalNetForImageClassification,
       FocalNetForMaskedImageModeling,
       FocalNetModel,
   )
   from transformers.models.focalnet.modeling_focalnet import FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
   from PIL import Image

   from transformers import AutoImageProcessor






class 				snake_case__     :


 def __init__(				self  ,						lowerCamelCase  ,						lowerCamelCase=13  ,						lowerCamelCase=32  ,						lowerCamelCase=2  ,						lowerCamelCase=3  ,						lowerCamelCase=16  ,						lowerCamelCase=[32, 64, 128]  ,						lowerCamelCase=[1, 2, 1]  ,						lowerCamelCase=[2, 2, 4]  ,						lowerCamelCase=2  ,						lowerCamelCase=2.0  ,						lowerCamelCase=True  ,						lowerCamelCase=0.0  ,						lowerCamelCase=0.0  ,						lowerCamelCase=0.1  ,						lowerCamelCase="gelu"  ,						lowerCamelCase=False  ,						lowerCamelCase=True  ,						lowerCamelCase=0.02  ,						lowerCamelCase=1E-5  ,						lowerCamelCase=True  ,						lowerCamelCase=None  ,						lowerCamelCase=True  ,						lowerCamelCase=10  ,						lowerCamelCase=8  ,						lowerCamelCase=["stage1", "stage2"]  ,						lowerCamelCase=[1, 2]  ,						):
        __a     				=  parent
        __a     				=  batch_size
        __a     				=  image_size
        __a     				=  patch_size
        __a     				=  num_channels
        __a     				=  embed_dim
        __a     				=  hidden_sizes
        __a     				=  depths
        __a     				=  num_heads
        __a     				=  window_size
        __a     				=  mlp_ratio
        __a     				=  qkv_bias
        __a     				=  hidden_dropout_prob
        __a     				=  attention_probs_dropout_prob
        __a     				=  drop_path_rate
        __a     				=  hidden_act
        __a     				=  use_absolute_embeddings
        __a     				=  patch_norm
        __a     				=  layer_norm_eps
        __a     				=  initializer_range
        __a     				=  is_training
        __a     				=  scope
        __a     				=  use_labels
        __a     				=  type_sequence_label_size
        __a     				=  encoder_stride
        __a     				=  out_features
        __a     				=  out_indices


 def 		a__ (				self		):
        __a     				=  floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]		)

        __a     				=  None
        if self.use_labels:
               __a     				=  ids_tensor([self.batch_size]  ,						self.type_sequence_label_size		)

        __a     				=  self.get_config()

        return config, pixel_values, labels


 def 		a__ (				self		):
        return FocalNetConfig(
            image_size=self.image_size  ,						patch_size=self.patch_size  ,						num_channels=self.num_channels  ,						embed_dim=self.embed_dim  ,						hidden_sizes=self.hidden_sizes  ,						depths=self.depths  ,						num_heads=self.num_heads  ,						window_size=self.window_size  ,						mlp_ratio=self.mlp_ratio  ,						qkv_bias=self.qkv_bias  ,						hidden_dropout_prob=self.hidden_dropout_prob  ,						attention_probs_dropout_prob=self.attention_probs_dropout_prob  ,						drop_path_rate=self.drop_path_rate  ,						hidden_act=self.hidden_act  ,						use_absolute_embeddings=self.use_absolute_embeddings  ,						path_norm=self.patch_norm  ,						layer_norm_eps=self.layer_norm_eps  ,						initializer_range=self.initializer_range  ,						encoder_stride=self.encoder_stride  ,						out_features=self.out_features  ,						out_indices=self.out_indices  ,						)


 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase		):
        __a     				=  FocalNetModel(config=lowerCamelCase		)
        model.to(lowerCamelCase		)
        model.eval()
        __a     				=  model(lowerCamelCase		)

        __a     				=  ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths		) - 1))
        __a     				=  int(config.embed_dim * 2 ** (len(config.depths		) - 1)		)

        self.parent.assertEqual(result.last_hidden_state.shape  ,						(self.batch_size, expected_seq_len, expected_dim)		)


 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase		):
        __a     				=  FocalNetBackbone(config=lowerCamelCase		)
        model.to(lowerCamelCase		)
        model.eval()
        __a     				=  model(lowerCamelCase		)

        # verify feature maps
        self.parent.assertEqual(len(result.feature_maps		)  ,						len(config.out_features		)		)
        self.parent.assertListEqual(list(result.feature_maps[0].shape		)  ,						[self.batch_size, self.image_size, 8, 8]		)

        # verify channels
        self.parent.assertEqual(len(model.channels		)  ,						len(config.out_features		)		)
        self.parent.assertListEqual(model.channels  ,						config.hidden_sizes[:-1]		)

        # verify backbone works with out_features=None
        __a     				=  None
        __a     				=  FocalNetBackbone(config=lowerCamelCase		)
        model.to(lowerCamelCase		)
        model.eval()
        __a     				=  model(lowerCamelCase		)

        # verify feature maps
        self.parent.assertEqual(len(result.feature_maps		)  ,						1		)
        self.parent.assertListEqual(list(result.feature_maps[0].shape		)  ,						[self.batch_size, self.image_size * 2, 4, 4]		)

        # verify channels
        self.parent.assertEqual(len(model.channels		)  ,						1		)
        self.parent.assertListEqual(model.channels  ,						[config.hidden_sizes[-1]]		)


 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase		):
        __a     				=  FocalNetForMaskedImageModeling(config=lowerCamelCase		)
        model.to(lowerCamelCase		)
        model.eval()
        __a     				=  model(lowerCamelCase		)
        self.parent.assertEqual(
            result.reconstruction.shape  ,						(self.batch_size, self.num_channels, self.image_size, self.image_size)		)

        # test greyscale images
        __a     				=  1
        __a     				=  FocalNetForMaskedImageModeling(lowerCamelCase		)
        model.to(lowerCamelCase		)
        model.eval()

        __a     				=  floats_tensor([self.batch_size, 1, self.image_size, self.image_size]		)
        __a     				=  model(lowerCamelCase		)
        self.parent.assertEqual(result.reconstruction.shape  ,						(self.batch_size, 1, self.image_size, self.image_size)		)


 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase		):
        __a     				=  self.type_sequence_label_size
        __a     				=  FocalNetForImageClassification(lowerCamelCase		)
        model.to(lowerCamelCase		)
        model.eval()
        __a     				=  model(lowerCamelCase  ,						labels=lowerCamelCase		)
        self.parent.assertEqual(result.logits.shape  ,						(self.batch_size, self.type_sequence_label_size)		)

        # test greyscale images
        __a     				=  1
        __a     				=  FocalNetForImageClassification(lowerCamelCase		)
        model.to(lowerCamelCase		)
        model.eval()

        __a     				=  floats_tensor([self.batch_size, 1, self.image_size, self.image_size]		)
        __a     				=  model(lowerCamelCase		)
        self.parent.assertEqual(result.logits.shape  ,						(self.batch_size, self.type_sequence_label_size)		)






 def 		a__ (				self		):
        __a     				=  self.prepare_config_and_inputs()

        __a				, __a				, __a     				=  config_and_inputs
        __a     				=  {"pixel_values": pixel_values}
        return config, inputs_dict






@require_torch
class 				snake_case__     (   snake_case_,		snake_case_,		unittest.TestCase   ):
 _snake_case   :			Union[str, Any]           =		(
     (
         FocalNetModel,
         FocalNetForImageClassification,
         FocalNetForMaskedImageModeling,
         FocalNetBackbone,
     )
     if is_torch_available()
     else ()
 )
 _snake_case   :			Tuple           =		(
     {"""feature-extraction""": FocalNetModel, """image-classification""": FocalNetForImageClassification}
     if is_torch_available()
     else {}
 )
 _snake_case   :			str           =		False

 _snake_case   :			List[str]           =		False
 _snake_case   :			Tuple           =		False
 _snake_case   :			Dict           =		False
 _snake_case   :			int           =		False


 def 		a__ (				self		):
        __a     				=  FocalNetModelTester(self		)
        __a     				=  ConfigTester(self  ,						config_class=lowerCamelCase  ,						embed_dim=37  ,						has_text_modality=lowerCamelCase		)


 def 		a__ (				self		):
        self.create_and_test_config_common_properties()
        self.config_tester.create_and_test_config_to_json_string()
        self.config_tester.create_and_test_config_to_json_file()
        self.config_tester.create_and_test_config_from_and_save_pretrained()
        self.config_tester.create_and_test_config_with_num_labels()
        self.config_tester.check_config_can_be_init_without_params()
        self.config_tester.check_config_arguments_init()


 def 		a__ (				self		):
        return


 def 		a__ (				self		):
        __a     				=  self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*lowerCamelCase		)


 def 		a__ (				self		):
        __a     				=  self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_backbone(*lowerCamelCase		)


 def 		a__ (				self		):
        __a     				=  self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_masked_image_modeling(*lowerCamelCase		)


 def 		a__ (				self		):
        __a     				=  self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_image_classification(*lowerCamelCase		)


 @unittest.skip(reason="FocalNet does not use inputs_embeds"		)
 def 		a__ (				self		):
        pass


 @unittest.skip(reason="FocalNet does not use feedforward chunking"		)
 def 		a__ (				self		):
        pass


 def 		a__ (				self		):
        __a				, __a     				=  self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes[:-1]:
               __a     				=  model_class(lowerCamelCase		)
               self.assertIsInstance(model.get_input_embeddings()  ,						(nn.Module)		)
               __a     				=  model.get_output_embeddings()
               self.assertTrue(x is None or isinstance(lowerCamelCase  ,						nn.Linear		)		)


 def 		a__ (				self		):
        __a				, __a     				=  self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes[:-1]:
               __a     				=  model_class(lowerCamelCase		)
               __a     				=  inspect.signature(model.forward		)
               # signature.parameters is an OrderedDict => so arg_names order is deterministic
               __a     				=  [*signature.parameters.keys()]

               __a     				=  ["pixel_values"]
               self.assertListEqual(arg_names[:1]  ,						lowerCamelCase		)


 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase		):
        __a     				=  model_class(lowerCamelCase		)
        model.to(lowerCamelCase		)
        model.eval()

        with torch.no_grad():
               __a     				=  model(**self._prepare_for_class(lowerCamelCase  ,						lowerCamelCase		)		)

        __a     				=  outputs.hidden_states

        __a     				=  getattr(
            self.model_tester  ,						"expected_num_hidden_layers"  ,						len(self.model_tester.depths		) + 1		)
        self.assertEqual(len(lowerCamelCase		)  ,						lowerCamelCase		)

        # FocalNet has a different seq_length
        __a     				=  (
            config.patch_size
            if isinstance(config.patch_size  ,						collections.abc.Iterable		)
            else (config.patch_size, config.patch_size)
        )

        __a     				=  (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

        self.assertListEqual(
            list(hidden_states[0].shape[-2:]		)  ,						[num_patches, self.model_tester.embed_dim]  ,						)

        __a     				=  outputs.reshaped_hidden_states
        self.assertEqual(len(lowerCamelCase		)  ,						lowerCamelCase		)

        __a				, __a				, __a				, __a     				=  reshaped_hidden_states[0].shape
        __a     				=  (
            reshaped_hidden_states[0].view(lowerCamelCase  ,						lowerCamelCase  ,						height * width		).permute(0  ,						2  ,						1		)
        )
        self.assertListEqual(
            list(reshaped_hidden_states.shape[-2:]		)  ,						[num_patches, self.model_tester.embed_dim]  ,						)


 def 		a__ (				self		):
        __a				, __a     				=  self.model_tester.prepare_config_and_inputs_for_common()

        __a     				=  (
            self.model_tester.image_size
            if isinstance(self.model_tester.image_size  ,						collections.abc.Iterable		)
            else (self.model_tester.image_size, self.model_tester.image_size)
        )

        for model_class in self.all_model_classes[:-1]:
               __a     				=  True
               self.check_hidden_states_output(lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase		)

               # check that output_hidden_states also work using config
               del inputs_dict["output_hidden_states"]
               __a     				=  True

               self.check_hidden_states_output(lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase		)


 def 		a__ (				self		):
        __a				, __a     				=  self.model_tester.prepare_config_and_inputs_for_common()
        __a     				=  3

        __a     				=  (
            self.model_tester.image_size
            if isinstance(self.model_tester.image_size  ,						collections.abc.Iterable		)
            else (self.model_tester.image_size, self.model_tester.image_size)
        )
        __a     				=  (
            config.patch_size
            if isinstance(config.patch_size  ,						collections.abc.Iterable		)
            else (config.patch_size, config.patch_size)
        )

        __a     				=  image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
        __a     				=  image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

        for model_class in self.all_model_classes[:-1]:
               __a     				=  True
               self.check_hidden_states_output(lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase  ,						(padded_height, padded_width)		)

               # check that output_hidden_states also work using config
               del inputs_dict["output_hidden_states"]
               __a     				=  True
               self.check_hidden_states_output(lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase  ,						(padded_height, padded_width)		)


 @slow
 def 		a__ (				self		):
        for model_name in FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               __a     				=  FocalNetModel.from_pretrained(lowerCamelCase		)
               self.assertIsNotNone(lowerCamelCase		)






 def 		a__ (				self		):
        __a				, __a     				=  self.model_tester.prepare_config_and_inputs_for_common()

        __a     				=  _config_zero_init(lowerCamelCase		)
        for model_class in self.all_model_classes:
               __a     				=  model_class(config=lowerCamelCase		)
               for name, param in model.named_parameters():
                      if "embeddings" not in name and param.requires_grad:
                             self.assertIn(
                                 ((param.data.mean() * 1E9).round() / 1E9).item()  ,						[0.0, 1.0]  ,						msg=F"Parameter {name} of model {model_class} seems not properly initialized"  ,						)






@require_vision
@require_torch
class 				snake_case__     (   unittest.TestCase   ):


 @cached_property
 def 		a__ (				self		):
        # TODO update organization
        return AutoImageProcessor.from_pretrained("microsoft/focalnet-tiny"		) if is_vision_available() else None






 @slow
 def 		a__ (				self		):
        __a     				=  FocalNetForImageClassification.from_pretrained("microsoft/focalnet-tiny"		).to(lowerCamelCase		)
        __a     				=  self.default_image_processor

        __a     				=  Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"		)
        __a     				=  image_processor(images=lowerCamelCase  ,						return_tensors="pt"		).to(lowerCamelCase		)

        # forward pass
        with torch.no_grad():
               __a     				=  model(**lowerCamelCase		)

        # verify the logits
        __a     				=  torch.Size((1, 1000)		)
        self.assertEqual(outputs.logits.shape  ,						lowerCamelCase		)
        __a     				=  torch.tensor([0.2166, -0.4368, 0.2191]		).to(lowerCamelCase		)
        self.assertTrue(torch.allclose(outputs.logits[0, :3]  ,						lowerCamelCase  ,						atol=1E-4		)		)
        self.assertTrue(outputs.logits.argmax(dim=-1		).item()  ,						281		)






@require_torch
class 				snake_case__     (   snake_case_,		unittest.TestCase   ):
 _snake_case   :			Union[str, Any]           =		(FocalNetBackbone,) if is_torch_available() else ()
 _snake_case   :			int           =		FocalNetConfig

 _snake_case   :			int           =		False


 def 		a__ (				self		):
        __a     				=  FocalNetModelTester(self		)

"""simple docstring"""



import collections
import os
from typing import List, Optional, Tuple

from transformers.utils import is_jieba_available, requires_backends


if is_jieba_available():
   import jieba

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


SCREAMING_SNAKE_CASE__:Tuple			=	logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__:List[Any]			=	{"""vocab_file""": """vocab.txt"""}

SCREAMING_SNAKE_CASE__:Optional[int]			=	{
    """vocab_file""": {
        """openbmb/cpm-ant-10b""": """https://huggingface.co/openbmb/cpm-ant-10b/blob/main/vocab.txt""",
    },
}

SCREAMING_SNAKE_CASE__:Tuple			=	{
    """openbmb/cpm-ant-10b""": 1024,
}



def 					_lowerCamelCase(					a							):
       __a     				=  collections.OrderedDict()
       with open(a ,  "r" ,  encoding="utf-8"							) as reader:
              __a     				=  reader.readlines()
       for index, token in enumerate(a							):
              __a     				=  token.rstrip("\n"							)
              __a     				=  index
       return vocab






class 				snake_case__     (   snake_case_   ):


 def __init__(				self  ,						lowerCamelCase  ,						lowerCamelCase="<unk>"  ,						lowerCamelCase=200		):
        __a     				=  vocab
        __a     				=  unk_token
        __a     				=  max_input_chars_per_word






 def 		a__ (				self  ,						lowerCamelCase		):
        __a     				=  list(lowerCamelCase		)
        if len(lowerCamelCase		) > self.max_input_chars_per_word:
               return [self.unk_token]

        __a     				=  0
        __a     				=  []
        while start < len(lowerCamelCase		):
               __a     				=  len(lowerCamelCase		)
               __a     				=  None
               while start < end:
                      __a     				=  "".join(chars[start:end]		)
                      if substr in self.vocab:
                             __a     				=  substr
                             break
                      end -= 1
               if cur_substr is None:
                      sub_tokens.append(self.unk_token		)
                      start += 1
               else:
                      sub_tokens.append(lowerCamelCase		)
                      __a     				=  end

        return sub_tokens






class 				snake_case__     (   snake_case_   ):
 _snake_case   :			Optional[int]           =		VOCAB_FILES_NAMES
 _snake_case   :			Optional[int]           =		PRETRAINED_VOCAB_FILES_MAP
 _snake_case   :			Optional[Any]           =		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 _snake_case   :			int           =		["""input_ids""", """attention_mask"""]
 _snake_case   :			int           =		False


 def __init__(				self  ,						lowerCamelCase  ,						lowerCamelCase="<d>"  ,						lowerCamelCase="</d>"  ,						lowerCamelCase="<s>"  ,						lowerCamelCase="</s>"  ,						lowerCamelCase="<pad>"  ,						lowerCamelCase="<unk>"  ,						lowerCamelCase="</n>"  ,						lowerCamelCase="</_>"  ,						lowerCamelCase="left"  ,						**lowerCamelCase  ,						):
        requires_backends(self  ,						["jieba"]		)
        super().__init__(
            bod_token=lowerCamelCase  ,						eod_token=lowerCamelCase  ,						bos_token=lowerCamelCase  ,						eos_token=lowerCamelCase  ,						pad_token=lowerCamelCase  ,						unk_token=lowerCamelCase  ,						line_token=lowerCamelCase  ,						space_token=lowerCamelCase  ,						padding_side=lowerCamelCase  ,						**lowerCamelCase  ,						)
        __a     				=  bod_token
        __a     				=  eod_token
        __a     				=  load_vocab(lowerCamelCase		)
        __a     				=  self.encoder[space_token]
        __a     				=  self.encoder[line_token]

        del self.encoder[space_token]
        del self.encoder[line_token]

        __a     				=  collections.OrderedDict(sorted(self.encoder.items()  ,						key=lambda lowerCamelCase		: x[1]		)		)
        __a     				=  {v: k for k, v in self.encoder.items()}

        __a     				=  WordpieceTokenizer(vocab=self.encoder  ,						unk_token=self.unk_token		)


 @property
 def 		a__ (				self		):
        return self.encoder[self.bod_token]


 @property
 def 		a__ (				self		):
        return self.encoder[self.eod_token]


 @property
 def 		a__ (				self		):
        return self.encoder["\n"]


 @property
 def 		a__ (				self		):
        return len(self.encoder		)


 def 		a__ (				self		):
        return dict(self.encoder  ,						**self.added_tokens_encoder		)


 def 		a__ (				self  ,						lowerCamelCase		):
        __a     				=  []
        for x in jieba.cut(lowerCamelCase  ,						cut_all=lowerCamelCase		):
               output_tokens.extend(self.wordpiece_tokenizer.tokenize(lowerCamelCase		)		)
        return output_tokens


 def 		a__ (				self  ,						lowerCamelCase  ,						**lowerCamelCase		):
        __a     				=  [i for i in token_ids if i >= 0]
        __a     				=  [
            x for x in token_ids if x != self.pad_token_id and x != self.eos_token_id and x != self.bos_token_id
        ]
        return super()._decode(lowerCamelCase  ,						**lowerCamelCase		)


 def 		a__ (				self  ,						lowerCamelCase		):
        return token in self.encoder


 def 		a__ (				self  ,						lowerCamelCase		):
        return "".join(lowerCamelCase		)


 def 		a__ (				self  ,						lowerCamelCase		):
        return self.encoder.get(lowerCamelCase  ,						self.encoder.get(self.unk_token		)		)


 def 		a__ (				self  ,						lowerCamelCase		):
        return self.decoder.get(lowerCamelCase  ,						self.unk_token		)


 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase = None		):
        if os.path.isdir(lowerCamelCase		):
               __a     				=  os.path.join(
                   lowerCamelCase  ,						(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]		)
        else:
               __a     				=  (filename_prefix + "-" if filename_prefix else "") + save_directory
        __a     				=  0
        if " " in self.encoder:
               __a     				=  self.encoder[" "]
               del self.encoder[" "]
        if "\n" in self.encoder:
               __a     				=  self.encoder["\n"]
               del self.encoder["\n"]
        __a     				=  collections.OrderedDict(sorted(self.encoder.items()  ,						key=lambda lowerCamelCase		: x[1]		)		)
        with open(lowerCamelCase  ,						"w"  ,						encoding="utf-8"		) as writer:
               for token, token_index in self.encoder.items():
                      if index != token_index:
                             logger.warning(
                                 F"Saving vocabulary to {vocab_file}: vocabulary indices are not consecutive."
                                 " Please check that the vocabulary is not corrupted!"		)
                             __a     				=  token_index
                      writer.write(token + "\n"		)
                      index += 1
        return (vocab_file,)


 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase = None		):
        if token_ids_a is None:
               return [self.bos_token_id] + token_ids_a
        return [self.bos_token_id] + token_ids_a + [self.bos_token_id] + token_ids_a






 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase = None  ,						lowerCamelCase = False		):

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

        if token_ids_a is not None:
               return [1] + ([0] * len(lowerCamelCase		)) + [1] + ([0] * len(lowerCamelCase		))
        return [1] + ([0] * len(lowerCamelCase		))
