class_docstr: Transformer-based language model responsible for spell correction.
  Implementation of language model of \
      `ABINet <https://arxiv.org/pdf/2103.06495>`_.
  
  Args:
      dictionary (dict or :obj:`Dictionary`): The config for `Dictionary` or
          the instance of `Dictionary`. The dictionary must have an end
          token.
      d_model (int): Hidden size :math:`E` of model. Defaults to 512.
      n_head (int): Number of multi-attention heads.
      d_inner (int): Hidden size of feedforward network model.
      n_layers (int): The number of similar decoding layers.
      dropout (float): Dropout rate.
      detach_tokens (bool): Whether to block the gradient flow at input
       tokens.
      use_self_attn (bool): If True, use self attention in decoder layers,
          otherwise cross attention will be used.
      max_seq_len (int): Maximum sequence length :math:`T`. The
          sequence is usually generated from decoder. Defaults to 40.
      module_loss (dict, optional): Config to build loss. Defaults to None.
      postprocessor (dict, optional): Config to build postprocessor.
          Defaults to None.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to None.
class_docstr_tok: ["Transformer-based","language","model","responsible","for","spell","correction",".","Implementation","of","language","model","of","\\","`","ABINet","<","https",":","\/\/arxiv.org\/pdf\/2103.06495",">","`","_",".","Args",":","dictionary","(","dict","or",":","obj",":","`","Dictionary","`",")",":","The","config","for","`","Dictionary","`","or","the","instance","of","`","Dictionary","`",".","The","dictionary","must","have","an","end","token",".","d_model","(","int",")",":","Hidden","size",":","math",":","`","E","`","of","model",".","Defaults","to","512.","n_head","(","int",")",":","Number","of","multi-attention","heads",".","d_inner","(","int",")",":","Hidden","size","of","feedforward","network","model",".","n_layers","(","int",")",":","The","number","of","similar","decoding","layers",".","dropout","(","float",")",":","Dropout","rate",".","detach_tokens","(","bool",")",":","Whether","to","block","the","gradient","flow","at","input","tokens",".","use_self_attn","(","bool",")",":","If","True",",","use","self","attention","in","decoder","layers",",","otherwise","cross","attention","will","be","used",".","max_seq_len","(","int",")",":","Maximum","sequence","length",":","math",":","`","T","`",".","The","sequence","is","usually","generated","from","decoder",".","Defaults","to","40.","module_loss","(","dict",",","optional",")",":","Config","to","build","loss",".","Defaults","to","None",".","postprocessor","(","dict",",","optional",")",":","Config","to","build","postprocessor",".","Defaults","to","None",".","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","configs",".","Defaults","to","None","."]
docstr: Generate padding masks.
  
  Args:
      length (Tensor): Shape :math:`(N,)`.
      max_length (int): The maximum sequence length :math:`T`.
  
  Returns:
      Tensor: A bool tensor of shape :math:`(N, T)` with Trues on
      elements located over the length, or Falses elsewhere.
docstr_tok: ["Generate","padding","masks",".","Args",":","length","(","Tensor",")",":","Shape",":","math",":","`","(","N",",",")","`",".","max_length","(","int",")",":","The","maximum","sequence","length",":","math",":","`","T","`",".","Returns",":","Tensor",":","A","bool","tensor","of","shape",":","math",":","`","(","N",",","T",")","`","with","Trues","on","elements","located","over","the","length",",","or","Falses","elsewhere","."]
code: def _get_padding_mask(length: int, max_length: int) -> torch.Tensor:
      """Generate padding masks.
  
      Args:
          length (Tensor): Shape :math:`(N,)`.
          max_length (int): The maximum sequence length :math:`T`.
  
      Returns:
          Tensor: A bool tensor of shape :math:`(N, T)` with Trues on
          elements located over the length, or Falses elsewhere.
      """
      length = length.unsqueeze(-1)
      grid = torch.arange(
          0, max_length, device=length.device
      ).unsqueeze(0)
      return grid >= length
  
file_path: mmocr/mmocr/models/textrecog/decoders/abi_language_decoder.py
imports: import copy
  from typing import Dict, List, Optional, Sequence, Union
  import torch
  import torch.nn
  from mmcv.cnn.bricks.transformer import BaseTransformerLayer
  from mmengine.model import ModuleList
  from mmocr.models.common.dictionary import Dictionary
  from mmocr.models.common.modules import PositionalEncoding
  from mmocr.registry import MODELS
  from mmocr.structures import TextRecogDataSample
  from .base import BaseDecoder
label_desc: Use image node_id 6 for calling the ABILanguageDecoder obj's underlying member method code with example usage: obj._get_padding_mask(length, max_length) and returns: unknown