






'''simple docstring'''


from typing import List, Union

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


SCREAMING_SNAKE_CASE_				      =							logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_				      =							{
    "allenai/led-base-16384": "https://huggingface.co/allenai/led-base-16384/resolve/main/config.json",
    # See all LED models at https://huggingface.co/models?filter=led
}




class 							lowerCAmelCase					(							_SCREAMING_SNAKE_CASE   ):







   """simple docstring"""







   _A						=   'led'
   _A						=   {
       'num_attention_heads': 'encoder_attention_heads',
       'hidden_size': 'd_model',
       'attention_probs_dropout_prob': 'attention_dropout',
       'initializer_range': 'init_std',
   }



   def __init__( self   ,   _A=50265   ,   _A=16384   ,   _A=1024   ,   _A=12   ,   _A=4096   ,   _A=16   ,   _A=12   ,   _A=4096   ,   _A=16   ,   _A=0.0   ,   _A=0.0   ,   _A=True   ,   _A=True   ,   _A="gelu"   ,   _A=1024   ,   _A=0.1   ,   _A=0.0   ,   _A=0.0   ,   _A=0.02   ,   _A=2   ,   _A=0.0   ,   _A=1   ,   _A=0   ,   _A=2   ,   _A = 512   ,   **_A   ,   )    ->   Optional[int]:
    __a    :	Tuple									=						vocab_size
    __a    :	Optional[int]									=						max_encoder_position_embeddings
    __a    :	str									=						max_decoder_position_embeddings
    __a    :	List[Any]									=						d_model
    __a    :	List[Any]									=						encoder_ffn_dim
    __a    :	Tuple									=						encoder_layers
    __a    :	List[Any]									=						encoder_attention_heads
    __a    :	Union[str, Any]									=						decoder_ffn_dim
    __a    :	Union[str, Any]									=						decoder_layers
    __a    :	Optional[int]									=						decoder_attention_heads
    __a    :	List[Any]									=						dropout
    __a    :	List[Any]									=						attention_dropout
    __a    :	Optional[int]									=						activation_dropout
    __a    :	Optional[int]									=						activation_function
    __a    :	Optional[Any]									=						init_std
    __a    :	Tuple									=						encoder_layerdrop
    __a    :	Optional[Any]									=						decoder_layerdrop
    __a    :	Tuple									=						classifier_dropout
    __a    :	Optional[Any]									=						use_cache
    __a    :	Dict									=						encoder_layers
    __a    :	Union[str, Any]									=						attention_window

    super().__init__(
        pad_token_id=UpperCamelCase__   ,   bos_token_id=UpperCamelCase__   ,   eos_token_id=UpperCamelCase__   ,   is_encoder_decoder=UpperCamelCase__   ,   decoder_start_token_id=UpperCamelCase__   ,   **UpperCamelCase__   ,   )













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

SCREAMING_SNAKE_CASE_				      =							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   lowerCAmelCase__			(					cls		):
   return cls






def   lowerCAmelCase__			(					SCREAMING_SNAKE_CASE__       ,		SCREAMING_SNAKE_CASE__ = None       ,		SCREAMING_SNAKE_CASE__ = None       ,		SCREAMING_SNAKE_CASE__ = None       ,		SCREAMING_SNAKE_CASE__ = None       ,		):
 __a    :	int									=						device
 __a    :	Union[str, Any]									=						shape[0]

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

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

 return latents






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




