



'''simple docstring'''






import doctest
import logging
import os
import unittest
from pathlib import Path
from typing import List, Union

import transformers
from transformers.testing_utils import require_tf, require_torch, slow


lowerCAmelCase: Union[str, Any]							=						logging.getLogger()

@unittest.skip("""Temporarily disable the doc tests."""     )
@require_torch
@require_tf
@slow
class 							a__( unittest.TestCase     ):







    def       lowercase_	(				self			:  Optional[Any]						,      __snake_case			:  Path						,      __snake_case			:  Union[str, None] = None						,      __snake_case			:  Union[List[str], None] = None						,      __snake_case			:  Union[str, List[str], None] = None						,      __snake_case			:  bool = True						,      ):
      a						: int					       =					[file for file in os.listdir(__snake_case     ) if os.path.isfile(os.path.join(__snake_case						,      __snake_case     )     )]

      if identifier is not None:
        a						: List[str]					       =					[file for file in files if identifier in file]

      if n_identifier is not None:
        if isinstance(__snake_case						,      __snake_case     ):
          for n_ in n_identifier:
            a						: Optional[int]					       =					[file for file in files if n_ not in file]
        else:
          a						: Dict					       =					[file for file in files if n_identifier not in file]

      a						: Union[str, Any]					       =					ignore_files or []
      ignore_files.append('__init__.py'     )
      a						: List[Any]					       =					[file for file in files if file not in ignore_files]

      for file in files:
        # Open all files
        print('Testing'						,      __snake_case     )

        if only_modules:
          a						: int					       =					file.split('.'     )[0]
          try:
            a						: Any					       =					getattr(__snake_case						,      __snake_case     )
            a						: int					       =					doctest.DocTestSuite(__snake_case     )
            a						: int					       =					unittest.TextTestRunner().run(__snake_case     )
            self.assertIs(len(result.failures     )						,      0     )
          except AttributeError:
            logger.info(F"""{module_identifier} is not a module."""     )
        else:
          a						: Optional[Any]					       =					doctest.testfile(str('..' / directory / file     )						,      optionflags=doctest.ELLIPSIS     )
          self.assertIs(result.failed						,      0     )







    def       lowercase_	(				self			:  str     ):
      a						: Optional[Any]					       =					Path('src/transformers'     )
      a						: Optional[Any]					       =					'modeling'
      a						: Any					       =					[
          'modeling_ctrl.py',
          'modeling_tf_ctrl.py',
      ]
      self.analyze_directory(__snake_case						,      identifier=__snake_case						,      ignore_files=__snake_case     )







    def       lowercase_	(				self			:  List[Any]     ):
      a						: Tuple					       =					Path('src/transformers'     )
      a						: Tuple					       =					'tokenization'
      self.analyze_directory(__snake_case						,      identifier=__snake_case     )







    def       lowercase_	(				self			:  str     ):
      a						: Tuple					       =					Path('src/transformers'     )
      a						: List[str]					       =					'configuration'
      self.analyze_directory(__snake_case						,      identifier=__snake_case     )







    def       lowercase_	(				self			:  Any     ):
      a						: Tuple					       =					Path('src/transformers'     )
      a						: str					       =					['configuration', 'modeling', 'tokenization']
      self.analyze_directory(__snake_case						,      n_identifier=__snake_case     )







    def       lowercase_	(				self			:  Union[str, Any]     ):
      a						: str					       =					Path('docs/source'     )
      a						: List[Any]					       =					['favicon.ico']
      self.analyze_directory(__snake_case						,      ignore_files=__snake_case						,      only_modules=__snake_case     )




'''simple docstring'''






import argparse

from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection

from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline


if __name__ == "__main__":
     lowerCAmelCase: Any							=						argparse.ArgumentParser()

     parser.add_argument('--dump_path', default=None, type=str, required=True, help='Path to the output model.')

     parser.add_argument(
         '--txt2img_unclip',
         default='kakaobrain/karlo-v1-alpha',
         type=str,
         required=False,
         help='The pretrained txt2img unclip.',
     )

     lowerCAmelCase: Optional[int]							=						parser.parse_args()

     lowerCAmelCase: List[Any]							=						UnCLIPPipeline.from_pretrained(args.txtaimg_unclip)

     lowerCAmelCase: Optional[Any]							=						CLIPImageProcessor()
     lowerCAmelCase: Tuple							=						CLIPVisionModelWithProjection.from_pretrained('openai/clip-vit-large-patch14')

     lowerCAmelCase: List[str]							=						UnCLIPImageVariationPipeline(
         decoder=txtaimg.decoder,
         text_encoder=txtaimg.text_encoder,
         tokenizer=txtaimg.tokenizer,
         text_proj=txtaimg.text_proj,
         feature_extractor=feature_extractor,
         image_encoder=image_encoder,
         super_res_first=txtaimg.super_res_first,
         super_res_last=txtaimg.super_res_last,
         decoder_scheduler=txtaimg.decoder_scheduler,
         super_res_scheduler=txtaimg.super_res_scheduler,
     )

     imgaimg.save_pretrained(args.dump_path)