






'''simple docstring'''



import copy
import random

from transformers import CLIPTokenizer
class 							__SCREAMING_SNAKE_CASE       (							_lowerCAmelCase     ):




      def __init__(  self ,   *lowerCamelCase ,   **lowerCamelCase      )							->Dict:



         '''simple docstring'''
         super().__init__(*lowerCamelCase ,   **lowerCamelCase      )
         __a				     =    {}




      def  __UpperCamelCase							(  self ,   lowerCamelCase ,   *lowerCamelCase ,   **lowerCamelCase      )							->Optional[Any]:



         '''simple docstring'''
         __a				     =    super().add_tokens(lowerCamelCase ,   *lowerCamelCase ,   **lowerCamelCase      )
         if num_added_tokens == 0:
            raise ValueError(
                F"""The tokenizer already contains the token {placeholder_token}. Please pass a different"""
                ' `placeholder_token` that is not already in the tokenizer.'      )




      def  __UpperCamelCase							(  self ,   lowerCamelCase ,   *lowerCamelCase ,   lowerCamelCase=1 ,   **lowerCamelCase      )							->Union[str, Any]:



         '''simple docstring'''
         __a				     =    []
         if num_vec_per_token == 1:
            self.try_adding_tokens(lowerCamelCase ,   *lowerCamelCase ,   **lowerCamelCase      )
            output.append(lowerCamelCase      )
         else:
            __a				     =    []
            for i in range(lowerCamelCase      ):
               __a				     =    placeholder_token + F"""_{i}"""
               self.try_adding_tokens(lowerCamelCase ,   *lowerCamelCase ,   **lowerCamelCase      )
               output.append(lowerCamelCase      )
        # handle cases where there is a new placeholder token that contains the current placeholder token but is larger
         for token in self.token_map:
            if token in placeholder_token:
               raise ValueError(
                   F"""The tokenizer already has placeholder token {token} that can get confused with"""
                   F""" {placeholder_token}keep placeholder tokens independent"""      )
         __a				     =    output




      def  __UpperCamelCase							(  self ,   lowerCamelCase ,   lowerCamelCase=False ,   lowerCamelCase=1.0      )							->Any:



         '''simple docstring'''
         if isinstance(lowerCamelCase ,   lowerCamelCase      ):
            __a				     =    []
            for i in range(len(lowerCamelCase      )      ):
               output.append(self.replace_placeholder_tokens_in_text(text[i] ,   vector_shuffle=lowerCamelCase      )      )
            return output
         for placeholder_token in self.token_map:
            if placeholder_token in text:
               __a				     =    self.token_map[placeholder_token]
               __a				     =    tokens[: 1 + int(len(lowerCamelCase      ) * prop_tokens_to_load      )]
               if vector_shuffle:
                  __a				     =    copy.copy(lowerCamelCase      )
                  random.shuffle(lowerCamelCase      )
               __a				     =    text.replace(lowerCamelCase ,   ' '.join(lowerCamelCase      )      )
         return text




      def __call__(  self ,   lowerCamelCase ,   *lowerCamelCase ,   lowerCamelCase=False ,   lowerCamelCase=1.0 ,   **lowerCamelCase      )							->Any:



         '''simple docstring'''
         return super().__call__(
             self.replace_placeholder_tokens_in_text(
                 lowerCamelCase ,   vector_shuffle=lowerCamelCase ,   prop_tokens_to_load=lowerCamelCase      ) ,   *lowerCamelCase ,   **lowerCamelCase ,   )






      def  __UpperCamelCase							(  self ,   lowerCamelCase ,   *lowerCamelCase ,   lowerCamelCase=False ,   lowerCamelCase=1.0 ,   **lowerCamelCase      )							->Dict:



         '''simple docstring'''
         return super().encode(
             self.replace_placeholder_tokens_in_text(
                 lowerCamelCase ,   vector_shuffle=lowerCamelCase ,   prop_tokens_to_load=lowerCamelCase      ) ,   *lowerCamelCase ,   **lowerCamelCase ,   )







'''simple docstring'''



__UpperCamelCase      :       Optional[Any]      			=      [
    """DownloadConfig""",
    """DownloadManager""",
    """DownloadMode""",
    """StreamingDownloadManager""",
]

from .download_config import DownloadConfig
from .download_manager import DownloadManager, DownloadMode
from .streaming_download_manager import StreamingDownloadManager