


'''simple docstring'''





from ...configuration_utils import PretrainedConfig
from ...utils import logging


__lowerCamelCase       				=	logging.get_logger(__name__)

__lowerCamelCase       				=	{
    '''ZinengTang/tvlt-base''': '''https://huggingface.co/ZinengTang/tvlt-base/blob/main/config.json''',
}




class 							UpperCAmelCase ( _snake_case	):
 UpperCAmelCase				=				"tvlt"


 def __init__(			self       :  Optional[Any] ,					__lowerCamelCase       :  List[str]=2_2_4 ,					__lowerCamelCase       :  str=2_0_4_8 ,					__lowerCamelCase       :  Dict=1_2_8 ,					__lowerCamelCase       :  Dict=[1_6, 1_6] ,					__lowerCamelCase       :  int=[1_6, 1_6] ,					__lowerCamelCase       :  int=3 ,					__lowerCamelCase       :  Any=1 ,					__lowerCamelCase       :  Optional[int]=8 ,					__lowerCamelCase       :  Tuple=7_6_8 ,					__lowerCamelCase       :  Optional[Any]=1_2 ,					__lowerCamelCase       :  List[str]=1_2 ,					__lowerCamelCase       :  List[Any]=3_0_7_2 ,					__lowerCamelCase       :  Tuple="gelu" ,					__lowerCamelCase       :  Tuple=0.0 ,					__lowerCamelCase       :  List[Any]=0.0 ,					__lowerCamelCase       :  Union[str, Any]=0.02 ,					__lowerCamelCase       :  str=1e-6 ,					__lowerCamelCase       :  List[str]=True ,					__lowerCamelCase       :  Optional[Any]=False ,					__lowerCamelCase       :  List[str]=1_6 ,					__lowerCamelCase       :  Optional[int]=5_1_2 ,					__lowerCamelCase       :  Any=8 ,					__lowerCamelCase       :  List[Any]=2_0_4_8 ,					__lowerCamelCase       :  List[str]=0.75 ,					__lowerCamelCase       :  List[str]=0.15 ,					__lowerCamelCase       :  Union[str, Any]="frame-level" ,					__lowerCamelCase       :  List[str]=True ,					__lowerCamelCase       :  str=True ,					__lowerCamelCase       :  List[str]="classification" ,					**__lowerCamelCase       :  Optional[Any] ,					):
    super().__init__(**__lowerCamelCase   )

    if audio_mask_type not in ("frame-level", "patch_level"):
       raise ValueError(
           '''audio_mask_type must be one of two acceptable strategies - {\'frame_level\', \'patch-level\') '''
           f'''got {audio_mask_type}'''   )

    UpperCAmelCase__  :Union[str, Any]            =			image_size
    UpperCAmelCase__  :List[str]            =			spectrogram_length
    UpperCAmelCase__  :List[Any]            =			frequency_length
    UpperCAmelCase__  :str            =			image_patch_size
    UpperCAmelCase__  :Dict            =			audio_patch_size
    UpperCAmelCase__  :Union[str, Any]            =			num_image_channels
    UpperCAmelCase__  :Union[str, Any]            =			num_audio_channels
    UpperCAmelCase__  :Optional[int]            =			num_frames

    UpperCAmelCase__  :Dict            =			hidden_size
    UpperCAmelCase__  :Tuple            =			num_hidden_layers
    UpperCAmelCase__  :Optional[int]            =			num_attention_heads
    UpperCAmelCase__  :List[Any]            =			intermediate_size
    UpperCAmelCase__  :List[str]            =			hidden_act
    UpperCAmelCase__  :List[Any]            =			hidden_dropout_prob
    UpperCAmelCase__  :List[str]            =			attention_probs_dropout_prob
    UpperCAmelCase__  :Dict            =			initializer_range
    UpperCAmelCase__  :str            =			layer_norm_eps
    UpperCAmelCase__  :int            =			qkv_bias
    UpperCAmelCase__  :List[Any]            =			use_mean_pooling

    UpperCAmelCase__  :Optional[Any]            =			decoder_num_attention_heads
    UpperCAmelCase__  :List[Any]            =			decoder_hidden_size
    UpperCAmelCase__  :int            =			decoder_num_hidden_layers
    UpperCAmelCase__  :Optional[int]            =			decoder_intermediate_size
    UpperCAmelCase__  :Optional[Any]            =			pixel_mask_ratio
    UpperCAmelCase__  :Tuple            =			audio_mask_ratio
    UpperCAmelCase__  :List[str]            =			audio_mask_type

    UpperCAmelCase__  :Any            =			task_matching
    UpperCAmelCase__  :Tuple            =			task_mae
    UpperCAmelCase__  :Dict            =			loss_type







'''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       				=	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 					a__    (				cls	:			Optional[int]	):
       return cls


def 					a__    (				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,      ):
   UpperCAmelCase__  :Union[str, Any]            =			device
   UpperCAmelCase__  :List[Any]            =			shape[0]

   UpperCAmelCase__  :Tuple            =			layout or torch.strided
   UpperCAmelCase__  :Union[str, Any]            =			device or torch.device('''cpu'''	)

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

   return latents


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



