class_docstr: Transformer encoder consisting of *config.encoder_layers* self attention layers. Each layer is a
  [`WhisperEncoderLayer`].
  
  Args:
      config: WhisperConfig
      embed_tokens (nn.Embedding): output embedding
class_docstr_tok: ["Transformer","encoder","consisting","of","*","config.encoder_layers","*","self","attention","layers",".","Each","layer","is","a","[","`","WhisperEncoderLayer","`","]",".","Args",":","config",":","WhisperConfig","embed_tokens","(","nn.Embedding",")",":","output","embedding"]
code: def __init__(self, config: WhisperConfig):
      super().__init__(config)
      self.dropout = config.dropout
      self.layerdrop = config.encoder_layerdrop
  
      embed_dim = config.d_model
      self.num_mel_bins = config.num_mel_bins
      self.padding_idx = config.pad_token_id
      self.max_source_positions = config.max_source_positions
      self.embed_scale = (
          math.sqrt(embed_dim) if config.scale_embedding else 1.0
      )
  
      self.conv1 = nn.Conv1d(
          self.num_mel_bins, embed_dim, kernel_size=3, padding=1
      )
      self.conv2 = nn.Conv1d(
          embed_dim, embed_dim, kernel_size=3, stride=2, padding=1
      )
  
      self.embed_positions = nn.Embedding(
          self.max_source_positions, embed_dim
      )
  
      self.layers = nn.ModuleList(
          [
              WhisperEncoderLayer(config)
              for _ in range(config.encoder_layers)
          ]
      )
      self.layer_norm = nn.LayerNorm(config.d_model)
  
      self.gradient_checkpointing = False
      # Initialize weights and apply final processing
      self.post_init()
  
imports: import math
  import random
  from typing import Optional, Tuple
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_whisper import WhisperConfig
label_desc: Use image node_id 1 to create a new WhisperEncoder object from inherited base classes: WhisperPreTrainedModel with example: obj = WhisperEncoder(config)