class_docstr: Transformer encoder consisting of *config.encoder_layers* self attention layers. Each layer is a
  [`LDMBertEncoderLayer`].
  
  Args:
      config: LDMBertConfig
      embed_tokens (nn.Embedding): output embedding
class_docstr_tok: ["Transformer","encoder","consisting","of","*","config.encoder_layers","*","self","attention","layers",".","Each","layer","is","a","[","`","LDMBertEncoderLayer","`","]",".","Args",":","config",":","LDMBertConfig","embed_tokens","(","nn.Embedding",")",":","output","embedding"]
code: def __init__(self, config: LDMBertConfig):
      super().__init__(config)
  
      self.dropout = config.dropout
  
      embed_dim = config.d_model
      self.padding_idx = config.pad_token_id
      self.max_source_positions = config.max_position_embeddings
  
      self.embed_tokens = nn.Embedding(config.vocab_size, embed_dim)
      self.embed_positions = nn.Embedding(
          config.max_position_embeddings, embed_dim
      )
      self.layers = nn.ModuleList(
          [
              LDMBertEncoderLayer(config)
              for _ in range(config.encoder_layers)
          ]
      )
      self.layer_norm = nn.LayerNorm(embed_dim)
  
      self.gradient_checkpointing = False
      # Initialize weights and apply final processing
      self.post_init()
  
imports: import inspect
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn
  import torch.utils.checkpoint
  from transformers import PretrainedConfig, PreTrainedModel, PreTrainedTokenizer
  from transformers.activations import ACT2FN
  from transformers.modeling_outputs import BaseModelOutput
  from transformers.utils import logging
  from ...models import AutoencoderKL, UNet2DConditionModel, UNet2DModel, VQModel
  from ...schedulers import DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler
  from ...utils.torch_utils import randn_tensor
  from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput
label_desc: Use image node_id 1 to create a new LDMBertEncoder object from inherited base classes: LDMBertPreTrainedModel with example: obj = LDMBertEncoder(config)