


'''simple docstring'''



from argparse import ArgumentParser

from .env import EnvironmentCommand






def   lowerCamelCase							():
					__a			:       str					    =  ArgumentParser('Diffusers CLI tool'						,      usage='diffusers-cli <command> [<args>]'   )
					__a			:       Dict					    =  parser.add_subparsers(help='diffusers-cli command helpers'   )

					# Register commands
					EnvironmentCommand.register_subcommand(SCREAMING_SNAKE_CASE_   )

					# Let's go
					__a			:       str					    =  parser.parse_args()

					if not hasattr(SCREAMING_SNAKE_CASE_						,      'func'   ):
										parser.print_help()
										exit(1   )

					# Run
					__a			:       int					    =  args.func(SCREAMING_SNAKE_CASE_   )
					service.run()


if __name__ == "__main__":
	main()







import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel
class 	UpperCAmelCase_					(					UpperCamelCase    ):

   '''simple docstring'''




   __A :      Optional[int]     		=		"M-CLIP"






   def __init__(		self						,				__A=1024						,				__A=768						,				**__A ):






     """simple docstring"""





     lowerCamelCase :					str    =				transformerDimSize
     lowerCamelCase :					Any    =				imageDimSize
     super().__init__(**__A )



class 	UpperCAmelCase_					(					UpperCamelCase    ):

   '''simple docstring'''




   __A :      Tuple     		=		MCLIPConfig






   def __init__(		self						,				__A						,				*__A						,				**__A ):






     """simple docstring"""





     super().__init__(__A						,				*__A						,				**__A )
     lowerCamelCase :					Tuple    =				XLMRobertaModel(__A )
     lowerCamelCase :					Optional[Any]    =				torch.nn.Linear(
         in_features=config.transformerDimensions						,				out_features=config.numDims )






   def _snake_case    (		self						,				__A						,				__A ):






     """simple docstring"""





     lowerCamelCase :					Any    =				self.transformer(input_ids=__A						,				attention_mask=__A )[0]
     lowerCamelCase :					int    =				(embs * attention_mask.unsqueeze(2 )).sum(dim=1 ) / attention_mask.sum(dim=1 )[:, None]
     return self.LinearTransformation(__A ), embs



