class_docstr: Transformer-based Speech Encoder from OpenAI's Whisper Model:
  
  URL: https://github.com/openai/whisper
class_docstr_tok: ["Transformer-based","Speech","Encoder","from","OpenAI","'s","Whisper","Model",":","URL",":","https",":","\/\/github.com\/openai\/whisper"]
code: def whisper_encode(
      self,
      input: torch.Tensor,
      ilens: torch.Tensor = None,
  ) -> torch.Tensor:
      x = F.gelu(self.encoders.conv1(input))
      x = F.gelu(self.encoders.conv2(x))
      x = x.permute(0, 2, 1)
  
      n_frames = x.size(1)
      max_pos = self.encoders.positional_embedding.size(0)
      if n_frames <= max_pos:
          x = (
              x + self.encoders.positional_embedding[: x.size(1), :]
          ).to(x.dtype)
      else:
          # due to positional encoding, audios >30 sec won't be accepted
          x = x[:, :max_pos, :] + self.encoders.positional_embedding
  
      x = self.dropout(x)
  
      for layer, block in enumerate(self.encoders.blocks):
          x = block(x)
          if layer < len(self.encoders.blocks) - 1:
              x = self.dropout(x)
  
      x = self.encoders.ln_post(x)
  
      if ilens is not None:
          olens = (
              1
              + (
                  ilens
                  - self.encoders.conv2.kernel_size[0]
                  + 2 * self.encoders.conv2.padding[0]
              )
              // self.encoders.conv2.stride[0]
          )
          olens = torch.clamp(olens, max=max_pos)
      else:
          olens = None
  
      return x, olens
  
file_path: espnet/espnet2/asr/encoder/whisper_encoder.py
imports: import copy
  from typing import Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from typeguard import check_argument_types
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet2.asr.specaug.specaug import SpecAug
label_desc: Use image node_id 5 for calling the OpenAIWhisperEncoder obj's underlying member method code with example usage: obj.whisper_encode(input, ilens) and returns: x,  olens