
"""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

A_						       =				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	):
									return cls






def    lowercase	(  lowerCAmelCase__  ,lowerCAmelCase__ = None  ,lowerCAmelCase__ = None  ,lowerCAmelCase__ = None  ,lowerCAmelCase__ = None  ,):
			lowerCamelCase_ 		=     device
			lowerCamelCase_ 		=     shape[0]

			lowerCamelCase_ 		=     layout or torch.strided
			lowerCamelCase_ 		=     device or torch.device('''cpu'''	)

			if generator is not None:
						lowerCamelCase_ 		=     generator.device.type if not isinstance(lowerCAmelCase__  ,lowerCAmelCase__	) else generator[0].device.type
						if gen_device_type != device.type and gen_device_type == "cpu":
									lowerCamelCase_ 		=     '''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(lowerCAmelCase__  ,lowerCAmelCase__	):
						lowerCamelCase_ 		=     (1,) + shape[1:]
						lowerCamelCase_ 		=     [
						    torch.randn(lowerCAmelCase__  ,generator=generator[i]  ,device=lowerCAmelCase__  ,dtype=lowerCAmelCase__  ,layout=lowerCAmelCase__	)
						    for i in range(lowerCAmelCase__	)
						]
						lowerCamelCase_ 		=     torch.cat(lowerCAmelCase__  ,dim=0	).to(lowerCAmelCase__	)
			else:
						lowerCamelCase_ 		=     torch.randn(lowerCAmelCase__  ,generator=lowerCAmelCase__  ,device=lowerCAmelCase__  ,dtype=lowerCAmelCase__  ,layout=lowerCAmelCase__	).to(lowerCAmelCase__	)

			return latents






def    lowercase	(  lowerCAmelCase__	):
			if is_torch_version('''<'''  ,'''2.0.0'''	) or not hasattr(lowerCAmelCase__  ,'''_dynamo'''	):
						return False
			return isinstance(lowerCAmelCase__  ,torch._dynamo.eval_frame.OptimizedModule	)





"""simple docstring"""


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


A_						       =				{
    """configuration_flava""": [
        """FLAVA_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """FlavaConfig""",
        """FlavaImageCodebookConfig""",
        """FlavaImageConfig""",
        """FlavaMultimodalConfig""",
        """FlavaTextConfig""",
    ],
}

try:
						if not is_vision_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						A_						       =				["""FlavaFeatureExtractor"""]
						A_						       =				["""FlavaImageProcessor"""]
						A_						       =				["""FlavaProcessor"""]

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						A_						       =				[
						    """FLAVA_PRETRAINED_MODEL_ARCHIVE_LIST""",
						    """FlavaForPreTraining""",
						    """FlavaImageCodebook""",
						    """FlavaImageModel""",
						    """FlavaModel""",
						    """FlavaMultimodalModel""",
						    """FlavaPreTrainedModel""",
						    """FlavaTextModel""",
						]

if TYPE_CHECKING:
						from .configuration_flava import (
						    FLAVA_PRETRAINED_CONFIG_ARCHIVE_MAP,
						    FlavaConfig,
						    FlavaImageCodebookConfig,
						    FlavaImageConfig,
						    FlavaMultimodalConfig,
						    FlavaTextConfig,
						)

						try:
												if not is_vision_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .feature_extraction_flava import FlavaFeatureExtractor
												from .image_processing_flava import FlavaImageProcessor
												from .processing_flava import FlavaProcessor

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_flava import (
												    FLAVA_PRETRAINED_MODEL_ARCHIVE_LIST,
												    FlavaForPreTraining,
												    FlavaImageCodebook,
												    FlavaImageModel,
												    FlavaModel,
												    FlavaMultimodalModel,
												    FlavaPreTrainedModel,
												    FlavaTextModel,
												)

else:
						import sys

						A_						       =				_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



