


"""simple docstring"""


import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_funnel import FunnelTokenizer


A  :     Union[str, Any]    					=    logging.get_logger(__name__)

A  :     List[Any]    					=    {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

A  :     List[Any]    					=    [
    "small",
    "small-base",
    "medium",
    "medium-base",
    "intermediate",
    "intermediate-base",
    "large",
    "large-base",
    "xlarge",
    "xlarge-base",
]

A  :     Optional[int]    					=    {
    "vocab_file": {
        "funnel-transformer/small": "https://huggingface.co/funnel-transformer/small/resolve/main/vocab.txt",
        "funnel-transformer/small-base": "https://huggingface.co/funnel-transformer/small-base/resolve/main/vocab.txt",
        "funnel-transformer/medium": "https://huggingface.co/funnel-transformer/medium/resolve/main/vocab.txt",
        "funnel-transformer/medium-base": (
            "https://huggingface.co/funnel-transformer/medium-base/resolve/main/vocab.txt"
        ),
        "funnel-transformer/intermediate": (
            "https://huggingface.co/funnel-transformer/intermediate/resolve/main/vocab.txt"
        ),
        "funnel-transformer/intermediate-base": (
            "https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/vocab.txt"
        ),
        "funnel-transformer/large": "https://huggingface.co/funnel-transformer/large/resolve/main/vocab.txt",
        "funnel-transformer/large-base": "https://huggingface.co/funnel-transformer/large-base/resolve/main/vocab.txt",
        "funnel-transformer/xlarge": "https://huggingface.co/funnel-transformer/xlarge/resolve/main/vocab.txt",
        "funnel-transformer/xlarge-base": (
            "https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/vocab.txt"
        ),
    },
    "tokenizer_file": {
        "funnel-transformer/small": "https://huggingface.co/funnel-transformer/small/resolve/main/tokenizer.json",
        "funnel-transformer/small-base": (
            "https://huggingface.co/funnel-transformer/small-base/resolve/main/tokenizer.json"
        ),
        "funnel-transformer/medium": "https://huggingface.co/funnel-transformer/medium/resolve/main/tokenizer.json",
        "funnel-transformer/medium-base": (
            "https://huggingface.co/funnel-transformer/medium-base/resolve/main/tokenizer.json"
        ),
        "funnel-transformer/intermediate": (
            "https://huggingface.co/funnel-transformer/intermediate/resolve/main/tokenizer.json"
        ),
        "funnel-transformer/intermediate-base": (
            "https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/tokenizer.json"
        ),
        "funnel-transformer/large": "https://huggingface.co/funnel-transformer/large/resolve/main/tokenizer.json",
        "funnel-transformer/large-base": (
            "https://huggingface.co/funnel-transformer/large-base/resolve/main/tokenizer.json"
        ),
        "funnel-transformer/xlarge": "https://huggingface.co/funnel-transformer/xlarge/resolve/main/tokenizer.json",
        "funnel-transformer/xlarge-base": (
            "https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/tokenizer.json"
        ),
    },
}
A  :     Union[str, Any]    					=    {f'''funnel-transformer/{name}''': 512 for name in _model_names}
A  :     Union[str, Any]    					=    {f'''funnel-transformer/{name}''': {"do_lower_case": True} for name in _model_names}
class 						_UpperCamelCase						(     lowercase__	):
							'''simple docstring'''







							__UpperCAmelCase		:					str          =VOCAB_FILES_NAMES
							__UpperCAmelCase		:					Any          =PRETRAINED_VOCAB_FILES_MAP
							__UpperCAmelCase		:					Union[str, Any]          =PRETRAINED_INIT_CONFIGURATION
							__UpperCAmelCase		:					Dict          =FunnelTokenizer
							__UpperCAmelCase		:					str          =PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							__UpperCAmelCase		:					str          =2

							def __init__(  self					,     __a=None					,     __a=None					,     __a=True					,     __a="<unk>"					,     __a="<sep>"					,     __a="<pad>"					,     __a="<cls>"					,     __a="<mask>"					,     __a="<s>"					,     __a="</s>"					,     __a=True					,     __a=True					,     __a=None					,     __a="##"					,     **__a					,     ):
										super().__init__(
										    __lowerCamelCase					,     tokenizer_file=__lowerCamelCase					,     do_lower_case=__lowerCamelCase					,     unk_token=__lowerCamelCase					,     sep_token=__lowerCamelCase					,     pad_token=__lowerCamelCase					,     cls_token=__lowerCamelCase					,     mask_token=__lowerCamelCase					,     bos_token=__lowerCamelCase					,     eos_token=__lowerCamelCase					,     clean_text=__lowerCamelCase					,     tokenize_chinese_chars=__lowerCamelCase					,     strip_accents=__lowerCamelCase					,     wordpieces_prefix=__lowerCamelCase					,     **__lowerCamelCase					,     )

										__lowerCAmelCase       					=    json.loads(self.backend_tokenizer.normalizer.__getstate__()			)
										if (
										    normalizer_state.get("lowercase"					,     __lowerCamelCase			) != do_lower_case
										    or normalizer_state.get("strip_accents"					,     __lowerCamelCase			) != strip_accents
										    or normalizer_state.get("handle_chinese_chars"					,     __lowerCamelCase			) != tokenize_chinese_chars
										):
													__lowerCAmelCase       					=    getattr(__lowerCamelCase					,     normalizer_state.pop("type"			)			)
													__lowerCAmelCase       					=    do_lower_case
													__lowerCAmelCase       					=    strip_accents
													__lowerCAmelCase       					=    tokenize_chinese_chars
													__lowerCAmelCase       					=    normalizer_class(**__lowerCamelCase			)

										__lowerCAmelCase       					=    do_lower_case

							def     snake_case       (  self					,     __a					,     __a=None			):
										__lowerCAmelCase       					=    [self.cls_token_id] + token_ids_a + [self.sep_token_id]

										if token_ids_a:
													output += token_ids_a + [self.sep_token_id]

										return output

							def     snake_case       (  self					,     __a					,     __a = None			):
										__lowerCAmelCase       					=    [self.sep_token_id]
										__lowerCAmelCase       					=    [self.cls_token_id]
										if token_ids_a is None:
													return len(cls			) * [self.cls_token_type_id] + len(token_ids_a + sep			) * [0]
										return len(cls			) * [self.cls_token_type_id] + len(token_ids_a + sep			) * [0] + len(token_ids_a + sep			) * [1]



							def     snake_case       (  self					,     __a					,     __a = None			):
										__lowerCAmelCase       					=    self._tokenizer.model.save(__lowerCamelCase					,     name=__lowerCamelCase			)
										return tuple(__lowerCamelCase			)








"""simple docstring"""


from manim import *
class 						_UpperCamelCase						(     lowerCAmelCase__	):
							'''simple docstring'''







							def     snake_case       (  self			):
										__lowerCAmelCase       					=    Rectangle(height=0.5					,     width=0.5			)
										__lowerCAmelCase       					=    Rectangle(height=0.4_6					,     width=0.4_6			).set_stroke(width=0			)

										__lowerCAmelCase       					=    Rectangle(height=0.2_5					,     width=0.2_5			)

										__lowerCAmelCase       					=    [mem.copy() for i in range(6			)]
										__lowerCAmelCase       					=    [mem.copy() for i in range(6			)]
										__lowerCAmelCase       					=    VGroup(*__a			).arrange(__a					,     buff=0			)
										__lowerCAmelCase       					=    VGroup(*__a			).arrange(__a					,     buff=0			)
										__lowerCAmelCase       					=    VGroup(__a					,     __a			).arrange(__a					,     buff=0			)
										__lowerCAmelCase       					=    Text("CPU"					,     font_size=24			)
										__lowerCAmelCase       					=    Group(__a					,     __a			).arrange(__a					,     buff=0.5					,     aligned_edge=__a			)
										cpu.move_to([-2.5, -0.5, 0]			)
										self.add(__a			)

										__lowerCAmelCase       					=    [mem.copy() for i in range(4			)]
										__lowerCAmelCase       					=    VGroup(*__a			).arrange(__a					,     buff=0			)
										__lowerCAmelCase       					=    Text("GPU"					,     font_size=24			)
										__lowerCAmelCase       					=    Group(__a					,     __a			).arrange(__a					,     buff=0.5					,     aligned_edge=__a			)
										gpu.move_to([-1, -1, 0]			)
										self.add(__a			)

										__lowerCAmelCase       					=    [mem.copy() for i in range(6			)]
										__lowerCAmelCase       					=    VGroup(*__a			).arrange(__a					,     buff=0			)

										__lowerCAmelCase       					=    Text("Model"					,     font_size=24			)
										__lowerCAmelCase       					=    Group(__a					,     __a			).arrange(__a					,     buff=0.5					,     aligned_edge=__a			)
										model.move_to([3, -1.0, 0]			)
										self.add(__a			)

										__lowerCAmelCase       					=    []
										__lowerCAmelCase       					=    []

										for i, rect in enumerate(__a			):
													__lowerCAmelCase       					=    fill.copy().set_fill(__a					,     opacity=0.8			)
													target.move_to(__a			)
													model_arr.append(__a			)

													__lowerCAmelCase       					=    Rectangle(height=0.4_6					,     width=0.4_6			).set_stroke(width=0.0			).set_fill(__a					,     opacity=0.8			)
													cpu_target.move_to(cpu_left_col_base[i]			)
													model_cpu_arr.append(__a			)

										self.add(*__a					,     *__a			)

										__lowerCAmelCase       					=    [meta_mem.copy() for i in range(6			)]
										__lowerCAmelCase       					=    [meta_mem.copy() for i in range(6			)]
										__lowerCAmelCase       					=    VGroup(*__a			).arrange(__a					,     buff=0			)
										__lowerCAmelCase       					=    VGroup(*__a			).arrange(__a					,     buff=0			)
										__lowerCAmelCase       					=    VGroup(__a					,     __a			).arrange(__a					,     buff=0			)
										__lowerCAmelCase       					=    Text("Disk"					,     font_size=24			)
										__lowerCAmelCase       					=    Group(__a					,     __a			).arrange(__a					,     buff=0.5					,     aligned_edge=__a			)
										disk.move_to([-4, -1.2_5, 0]			)
										self.add(__a					,     __a			)

										__lowerCAmelCase       					=    Square(side_length=2.2			)
										key.move_to([-5, 2, 0]			)

										__lowerCAmelCase       					=    MarkupText(
										    f"<b>Key:</b>\n\n<span fgcolor='{YELLOW}'>●</span> Empty Model"					,     font_size=18					,     )

										key_text.move_to([-5, 2.4, 0]			)

										self.add(__a					,     __a			)

										__lowerCAmelCase       					=    MarkupText(
										    f"<span fgcolor='{BLUE}'>●</span> Checkpoint"					,     font_size=18					,     )

										blue_text.next_to(__a					,     DOWN * 2.4					,     aligned_edge=key_text.get_left()			)
										self.add(__a			)

										__lowerCAmelCase       					=    MarkupText(
										    f"Now watch as an input is passed through the model\nand how the memory is utilized and handled."					,     font_size=24					,     )
										step_a.move_to([2, 2, 0]			)

										self.play(Write(__a			)			)

										__lowerCAmelCase       					=    Square(0.3			)
										input.set_fill(__a					,     opacity=1.0			)
										input.set_stroke(width=0.0			)
										input.next_to(model_base[0]					,     __a					,     buff=0.5			)

										self.play(Write(__a			)			)

										input.generate_target()
										input.target.next_to(model_arr[0]					,     direction=__a					,     buff=0.0_2			)
										self.play(MoveToTarget(__a			)			)

										self.play(FadeOut(__a			)			)

										__lowerCAmelCase       					=    Arrow(start=__a					,     end=__a					,     color=__a					,     buff=0.5			)
										a.next_to(model_arr[0].get_left()					,     __a					,     buff=0.2			)

										model_cpu_arr[0].generate_target()
										model_cpu_arr[0].target.move_to(gpu_rect[0]			)

										__lowerCAmelCase       					=    MarkupText(
										    f"As the input reaches a layer, the hook triggers\nand weights are moved from the CPU\nto the GPU and back."					,     font_size=24					,     )
										step_a.move_to([2, 2, 0]			)

										self.play(Write(__a					,     run_time=3			)			)

										__lowerCAmelCase       					=    {"run_time": 1, "fade_in": True, "fade_out": True, "buff": 0.0_2}

										self.play(
										    Write(__a			)					,     Circumscribe(model_arr[0]					,     color=__a					,     **__a			)					,     Circumscribe(model_cpu_arr[0]					,     color=__a					,     **__a			)					,     Circumscribe(gpu_rect[0]					,     color=__a					,     **__a			)					,     )
										self.play(MoveToTarget(model_cpu_arr[0]			)			)

										__lowerCAmelCase       					=    a.copy()
										for i in range(6			):
													a_c.next_to(model_arr[i].get_right() + 0.0_2					,     __a					,     buff=0.2			)

													input.generate_target()
													input.target.move_to(model_arr[i].get_right() + 0.0_2			)

													__lowerCAmelCase       					=    AnimationGroup(
													    FadeOut(__a					,     run_time=0.5			)					,     MoveToTarget(__a					,     run_time=0.5			)					,     FadeIn(__a					,     run_time=0.5			)					,     lag_ratio=0.2			)

													self.play(__a			)

													model_cpu_arr[i].generate_target()
													model_cpu_arr[i].target.move_to(cpu_left_col_base[i]			)

													if i < 5:
																model_cpu_arr[i + 1].generate_target()
																model_cpu_arr[i + 1].target.move_to(gpu_rect[0]			)
																if i >= 1:
																			__lowerCAmelCase       					=    0.7

																self.play(
																    Circumscribe(model_arr[i]					,     **__a			)					,     Circumscribe(cpu_left_col_base[i]					,     **__a			)					,     Circumscribe(cpu_left_col_base[i + 1]					,     color=__a					,     **__a			)					,     Circumscribe(gpu_rect[0]					,     color=__a					,     **__a			)					,     Circumscribe(model_arr[i + 1]					,     color=__a					,     **__a			)					,     )
																if i < 1:
																			self.play(
																			    MoveToTarget(model_cpu_arr[i]			)					,     MoveToTarget(model_cpu_arr[i + 1]			)					,     )
																else:
																			self.play(
																			    MoveToTarget(model_cpu_arr[i]					,     run_time=0.7			)					,     MoveToTarget(model_cpu_arr[i + 1]					,     run_time=0.7			)					,     )
													else:
																model_cpu_arr[i].generate_target()
																model_cpu_arr[i].target.move_to(cpu_left_col_base[-1]			)
																input.generate_target()
																input.target.next_to(model_arr[-1].get_right()					,     RIGHT + 0.0_2					,     buff=0.2			)

																self.play(
																    Circumscribe(model_arr[-1]					,     color=__a					,     **__a			)					,     Circumscribe(cpu_left_col_base[-1]					,     color=__a					,     **__a			)					,     Circumscribe(gpu_rect[0]					,     color=__a					,     **__a			)					,     )

																self.play(MoveToTarget(model_cpu_arr[i]			)			)

													__lowerCAmelCase       					=    a_c
													__lowerCAmelCase       					=    a_c.copy()

										input.generate_target()
										input.target.next_to(model_base[-1]					,     RIGHT + 0.0_2					,     buff=0.5			)
										self.play(
										    FadeOut(__a			)					,     FadeOut(__a					,     run_time=0.5			)					,     )

										__lowerCAmelCase       					=    MarkupText(f"Inference on a model too large for GPU memory\nis successfully completed."					,     font_size=24			)
										step_a.move_to([2, 2, 0]			)

										self.play(Write(__a					,     run_time=3			)					,     MoveToTarget(__a			)			)

										self.wait()




