class_docstr: RelativePositionBias module definition.
  
  Args:
      max_positions: Maximum number of relative positions.
class_docstr_tok: ["RelativePositionBias","module","definition",".","Args",":","max_positions",":","Maximum","number","of","relative","positions","."]
docstr: Compute relative position bias.
  
  Args:
      length: Sequence length.
  
  Returns:
      tile: Relative position bias. (L, L)
docstr_tok: ["Compute","relative","position","bias",".","Args",":","length",":","Sequence","length",".","Returns",":","tile",":","Relative","position","bias",".","(","L",",","L",")"]
code: def forward(self, length: int) -> torch.Tensor:
      """Compute relative position bias.
  
      Args:
          length: Sequence length.
  
      Returns:
          tile: Relative position bias. (L, L)
  
      """
      if length > self.max_positions:
          raise ValueError(
              f"Length {length} is too long for the maximum number of "
              f"allowed positions {self.max_positions}."
          )
  
      bias = self.relative_position_bias[
          (self.max_positions - length) : (
              self.max_positions + length - 1
          )
      ]
      bias = torch.nn.functional.pad(bias, (0, length))
  
      tile = torch.tile(bias, (length,))[:-length]
      tile = tile.view(length, (3 * length - 2))
  
      start = (2 * length - 1) // 2
      end = tile.size(1) - start
  
      tile = tile[:, start:end]
  
      return tile
  
file_path: espnet/espnet2/asr_transducer/decoder/modules/mega/positional_bias.py
imports: import math
  from typing import Tuple
  import torch
label_desc: Use image node_id 3 for calling the RelativePositionBias obj's underlying member method code with example usage: obj.forward(length) and returns: tile