code: 
  
  
  
  import gc
  import tempfile
  import unittest
  
  import numpy as np
  import torch
  
  from diffusers import VersatileDiffusionDualGuidedPipeline
  from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device
  
  
  _lowerCAmelCase       :      Tuple							=							False
  
  
  
  
  
  
  @nightly
  @require_torch_gpu
  class 			UpperCAmelCase_						(       unittest.TestCase		):
  
  
  
        def 		snake_case_      (  self  :			List[Any]		):
             # clean up the VRAM after each test
             super().tearDown()
             gc.collect()
             torch.cuda.empty_cache()
  
  
  
        def 		snake_case_      (  self  :			List[Any]		):
             _UpperCAmelCase    :			Optional[int]              =					VersatileDiffusionDualGuidedPipeline.from_pretrained("shi-labs/versatile-diffusion"		)
             # remove text_unet
             pipe.remove_unused_weights()
             pipe.to(A		)
             pipe.set_progress_bar_config(disable=A		)
  
             _UpperCAmelCase    :			Union[str, Any]              =					load_image(
                 "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"		)
  
             _UpperCAmelCase    :			List[str]              =					torch.manual_seed(0		)
             _UpperCAmelCase    :			str              =					pipe(
                 prompt="first prompt"  ,			image=A  ,			text_to_image_strength=0.75  ,			generator=A  ,			guidance_scale=7.5  ,			num_inference_steps=2  ,			output_type="numpy"  ,			).images
  
             with tempfile.TemporaryDirectory() as tmpdirname:
                  pipe.save_pretrained(A		)
                  _UpperCAmelCase    :			Dict              =					VersatileDiffusionDualGuidedPipeline.from_pretrained(A		)
  
             pipe.to(A		)
             pipe.set_progress_bar_config(disable=A		)
  
             _UpperCAmelCase    :			List[str]              =					generator.manual_seed(0		)
             _UpperCAmelCase    :			Dict              =					pipe(
                 prompt="first prompt"  ,			image=A  ,			text_to_image_strength=0.75  ,			generator=A  ,			guidance_scale=7.5  ,			num_inference_steps=2  ,			output_type="numpy"  ,			).images
  
             assert np.abs(image - new_image		).sum() < 1e-5, "Models don't have the same forward pass"
  
  
  
        def 		snake_case_      (  self  :			Optional[Any]		):
             _UpperCAmelCase    :			Union[str, Any]              =					VersatileDiffusionDualGuidedPipeline.from_pretrained("shi-labs/versatile-diffusion"		)
             pipe.remove_unused_weights()
             pipe.to(A		)
             pipe.set_progress_bar_config(disable=A		)
  
             _UpperCAmelCase    :			Any              =					"cyberpunk 2077"
             _UpperCAmelCase    :			List[str]              =					load_image(
                 "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"		)
             _UpperCAmelCase    :			List[str]              =					torch.manual_seed(0		)
             _UpperCAmelCase    :			Optional[int]              =					pipe(
                 prompt=A  ,			image=A  ,			text_to_image_strength=0.75  ,			generator=A  ,			guidance_scale=7.5  ,			num_inference_steps=5_0  ,			output_type="numpy"  ,			).images
  
             _UpperCAmelCase    :			Union[str, Any]              =					image[0, 2_5_3:2_5_6, 2_5_3:2_5_6, -1]
  
             assert image.shape == (1, 5_1_2, 5_1_2, 3)
             _UpperCAmelCase    :			Optional[int]              =					np.array([0.0_787, 0.0_849, 0.0_826, 0.0_812, 0.0_807, 0.0_795, 0.0_818, 0.0_798, 0.0_779]		)
  
             assert np.abs(image_slice.flatten() - expected_slice		).max() < 1e-2
  
style_context: 
  
  
  
  """simple docstring"""
  
  
  
  
  from arguments import TokenizerTrainingArguments
  from datasets import load_dataset
  from tqdm import tqdm
  
  from transformers import AutoTokenizer, HfArgumentParser
  from transformers.models.gpta.tokenization_gpta import bytes_to_unicode
  
  def 		__snake_case		(   SCREAMING_SNAKE_CASE__			:		str=10       )						->     List[Any]:
  
  
  
  
  
       '''simple docstring'''
  
       for _ in tqdm(range(0		,						args.n_examples		,						SCREAMING_SNAKE_CASE__       )       ):
            yield [next(SCREAMING_SNAKE_CASE__       )[args.text_column] for _ in range(SCREAMING_SNAKE_CASE__       )]
  
  
  # Configuration
  _lowerCAmelCase       :      Optional[Any]							=							HfArgumentParser(TokenizerTrainingArguments)
  _lowerCAmelCase       :      Dict							=							parser.parse_args()
  
  # Base tokenizer
  _lowerCAmelCase       :      int							=							AutoTokenizer.from_pretrained(args.base_tokenizer)
  _lowerCAmelCase       :      List[str]							=							list(bytes_to_unicode().values())
  
  # Load dataset
  _lowerCAmelCase       :      Dict							=							load_dataset(args.dataset_name, split="train", streaming=True)
  _lowerCAmelCase       :      List[Any]							=							iter(dataset)
  
  
  # Training and saving
  _lowerCAmelCase       :      List[str]							=							tokenizer.train_new_from_iterator(
      batch_iterator(), vocab_size=args.vocab_size, initial_alphabet=base_vocab
  )
  new_tokenizer.save_pretrained(args.tokenizer_name, push_to_hub=args.push_to_hub)
  