code: 
  
  
  
  
  '''simple docstring'''
  
  
  
  
  
  
  
  from typing import List, Optional, Tuple, Union
  
  from . import logging
  from .import_utils import is_torch_available, is_torch_version
  
  
  if is_torch_available():
  						import torch
  
  _lowerCamelCase							:		List[str]										=						logging.get_logger(__name__)  # pylint: disable=invalid-name
  
  try:
  						from torch._dynamo import allow_in_graph as maybe_allow_in_graph
  except (ImportError, ModuleNotFoundError):
  
  
  
  
  
  
  						def 	_lowercase	(			cls						):
  
  
  
  								'''simple docstring'''
  
  
  
  
  
  
  
  								return cls
  
  
  
  
  
  
  def 	_lowercase	(			lowercase_		,							lowercase_ = None		,							lowercase_ = None		,							lowercase_ = None		,							lowercase_ = None		,							):
  
  
  
  		'''simple docstring'''
  
  
  
  
  
  
  
  		_snake_case			 = device
  		_snake_case			 = shape[0]
  
  		_snake_case			 = layout or torch.strided
  		_snake_case			 = device or torch.device("cpu"						)
  
  		if generator is not None:
  				_snake_case			 = generator.device.type if not isinstance(lowercase_		,							lowercase_						) else generator[0].device.type
  				if gen_device_type != device.type and gen_device_type == "cpu":
  						_snake_case			 = "cpu"
  						if device != "mps":
  								logger.info(
  								    f'''The passed generator was created on \'cpu\' even though a tensor on {device} was expected.'''
  								    f''' Tensors will be created on \'cpu\' and then moved to {device}. Note that one can probably'''
  								    f''' slighly speed up this function by passing a generator that was created on the {device} device.'''						)
  				elif gen_device_type != device.type and gen_device_type == "cuda":
  						raise ValueError(f'''Cannot generate a {device} tensor from a generator of type {gen_device_type}.'''						)
  
  		if isinstance(lowercase_		,							lowercase_						):
  				_snake_case			 = (1,) + shape[1:]
  				_snake_case			 = [
  				    torch.randn(lowercase_		,							generator=generator[i]		,							device=lowercase_		,							dtype=lowercase_		,							layout=lowercase_						)
  				    for i in range(lowercase_						)
  				]
  				_snake_case			 = torch.cat(lowercase_		,							dim=0						).to(lowercase_						)
  		else:
  				_snake_case			 = torch.randn(lowercase_		,							generator=lowercase_		,							device=lowercase_		,							dtype=lowercase_		,							layout=lowercase_						).to(lowercase_						)
  
  		return latents
  
  
  
  
  
  
  def 	_lowercase	(			lowercase_						):
  
  
  
  		'''simple docstring'''
  
  
  
  
  
  
  
  		if is_torch_version("<"		,							"2.0.0"						) or not hasattr(lowercase_		,							"_dynamo"						):
  				return False
  		return isinstance(lowercase_		,							torch._dynamo.eval_frame.OptimizedModule						)
  
  
  
  
  
  
style_context: 
  
  
  
  
  '''simple docstring'''
  
  
  
  
  
  
  
  import warnings
  
  from ...utils import logging
  from .image_processing_vilt import ViltImageProcessor
  
  
  _lowerCamelCase							:		Optional[Any]										=						logging.get_logger(__name__)
  
  
  
  
  
  class   lowerCamelCase_							( UpperCAmelCase_							):
  
  
  
  
  					'''simple docstring'''
  
  
  
  
  
  
  					def __init__(					self,						*__UpperCamelCase,						**__UpperCamelCase				):
  							warnings.warn(
  							    "The class ViltFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
  							    " use ViltImageProcessor instead.",						__UpperCamelCase,						)
  							super().__init__(*__UpperCamelCase,						**__UpperCamelCase				)
  
  
  
  
  
  