class_docstr: This class defines the `ByteFormer <https://arxiv.org/pdf/2306.00238.pdf>`_
  architecture.
class_docstr_tok: ["This","class","defines","the","`","ByteFormer","<","https",":","\/\/arxiv.org\/pdf\/2306.00238.pdf",">","`","_","architecture","."]
docstr: Perform a forward pass on input bytes. The tensor is
  stored as an integer tensor of shape [batch_size, sequence_length].
  Integer tensors are used because @x usually contains mask tokens.
  
  Args:
      x: The input tensor of shape [batch_size, sequence_length].
  
  Returns:
      The output logits.
docstr_tok: ["Perform","a","forward","pass","on","input","bytes",".","The","tensor","is","stored","as","an","integer","tensor","of","shape","[","batch_size",",","sequence_length","]",".","Integer","tensors","are","used","because","@","x","usually","contains","mask","tokens",".","Args",":","x",":","The","input","tensor","of","shape","[","batch_size",",","sequence_length","]",".","Returns",":","The","output","logits","."]
code: def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
      """
      Perform a forward pass on input bytes. The tensor is
      stored as an integer tensor of shape [batch_size, sequence_length].
      Integer tensors are used because @x usually contains mask tokens.
  
      Args:
          x: The input tensor of shape [batch_size, sequence_length].
  
      Returns:
          The output logits.
      """
      x, key_padding_mask = self.get_backbone_inputs(x)
      x, attn_mask = self.backbone_forward(x, key_padding_mask)
  
      attn_mask = attn_mask.view(x.shape[0], x.shape[1], 1)
      x[(attn_mask == float("-inf")).expand(-1, -1, x.shape[-1])] = 0
      norms = (attn_mask == 0).sum(dim=1)
      x = torch.sum(x, dim=1) / norms
      x = self.classifier(x)
      return x
  
imports: import argparse
  import math
  from typing import Dict, Optional, Tuple, Union
  import numpy
  import torch
  from torch import Tensor, nn
  from torch.nn import init
  from cvnets.layers import LinearLayer, embedding, get_normalization_layer, normalization, positional_embedding, token_merging
  from cvnets.models import MODEL_REGISTRY, BaseAnyNNModel
  from cvnets.models.classification.config.byteformer import get_configuration
  from cvnets.modules import WindowedTransformerEncoder
label_desc: Use image node_id 9 for calling the ByteFormer obj's underlying member method code with example usage: obj.forward(x) and returns: x