

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						:Dict            = 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 			__snake_case	(   cls  :   Any						):



            """simple docstring"""

            return cls

def 			__snake_case	(   __UpperCamelCase  :   Union[Tuple, List]							,__UpperCamelCase  :   Optional[Union[List["torch.Generator"], "torch.Generator"]] = None							,__UpperCamelCase  :   Optional["torch.device"] = None							,__UpperCamelCase  :   Optional["torch.dtype"] = None							,__UpperCamelCase  :   Optional["torch.layout"] = None							,):



      """simple docstring"""

      A_	     =							device
      A_	     =							shape[0]

      A_	     =							layout or torch.strided
      A_	     =							device or torch.device("cpu"						)

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

      return latents



def 			__snake_case	(   __UpperCamelCase  :   Union[str, Any]						):



      """simple docstring"""

      if is_torch_version("<"							,"2.0.0"						) or not hasattr(__UpperCamelCase							,"_dynamo"						):
            return False
      return isinstance(__UpperCamelCase							,torch._dynamo.eval_frame.OptimizedModule						)


import warnings

from ...utils import logging
from .image_processing_mobilenet_va import MobileNetVaImageProcessor


__a						:Optional[int]            = logging.get_logger(__name__)

class      _a				( snake_case_							):




      """simple docstring"""

      def __init__(      self       :							List[Any]	, *UpperCAmelCase       :							Any	, **UpperCAmelCase       :							int  ):
            warnings.warn(
                "The class MobileNetV2FeatureExtractor is deprecated and will be removed in version 5 of Transformers."
                " Please use MobileNetV2ImageProcessor instead."	, UpperCAmelCase	, )
            super().__init__(*UpperCAmelCase	, **UpperCAmelCase  )