class_docstr: Vision Transformer w/ Relative Position Bias
  
  Differing from classic vit, this impl
    * uses relative position index (swin v1 / beit) or relative log coord + mlp (swin v2) pos embed
    * defaults to no class token (can be enabled)
    * defaults to global avg pool for head (can be changed)
    * layer-scale (residual branch gain) enabled
class_docstr_tok: ["Vision","Transformer","w\/","Relative","Position","Bias","Differing","from","classic","vit",",","this","impl","*","uses","relative","position","index","(","swin","v1","\/","beit",")","or","relative","log","coord","+","mlp","(","swin","v2",")","pos","embed","*","defaults","to","no","class","token","(","can","be","enabled",")","*","defaults","to","global","avg","pool","for","head","(","can","be","changed",")","*","layer-scale","(","residual","branch","gain",")","enabled"]
code: def forward_features(self, x):
      x = self.patch_embed(x)
      if self.cls_token is not None:
          x = torch.cat(
              (self.cls_token.expand(x.shape[0], -1, -1), x), dim=1
          )
  
      shared_rel_pos = (
          self.shared_rel_pos.get_bias()
          if self.shared_rel_pos is not None
          else None
      )
      for blk in self.blocks:
          if self.grad_checkpointing and not torch.jit.is_scripting():
              x = checkpoint(blk, x, shared_rel_pos=shared_rel_pos)
          else:
              x = blk(x, shared_rel_pos=shared_rel_pos)
      x = self.norm(x)
      return x
  
imports: import logging
  import math
  from functools import partial
  from typing import Optional, Tuple
  import torch
  import torch.nn
  from torch.jit import Final
  from torch.utils.checkpoint import checkpoint
  from timm.data import IMAGENET_INCEPTION_MEAN, IMAGENET_INCEPTION_STD
  from timm.layers import PatchEmbed, Mlp, DropPath, RelPosMlp, RelPosBias, use_fused_attn
  from ._builder import build_model_with_cfg
  from ._registry import generate_default_cfgs, register_model
label_desc: Use image node_id 8 for calling the VisionTransformerRelPos obj's underlying member method code with example usage: obj.forward_features(x) and returns: x