class_docstr: TransRAC model
  
  Args:
      backbone (`str`):
          Model name of pretrained backbone.
      num_frames (`int`):
          Number of video frames.
      scales (`list`):
          A list of scale numbers.
  
  Example:
      >>> import torch
      >>> from towhee.models import video_swin_transformer
      >>> from towhee.models.transrac import TransRAC
      >>>
      >>> dummy_video = torch.rand(1, 3, 4, 200, 200) # (bcthw)
      >>>
      >>> backbone = video_swin_transformer.create_model() # use default configs here
      >>> model = TransRAC(backbone=backbone, num_frames=4)
      >>>
      >>> out, out_matrix = model(dummy_video)
      >>> print(out.shape, out_matrix.shape)
      torch.Size([1, 4]), torch.Size([1, 12, 4, 4])
code: def forward(self, x):
      # bcthw
      _, _, t, _, _ = x.shape
      assert t == self.num_frames
  
      multi_scales = []
      for scale in self.scales:
          if scale == 4:
              x = self.replication_padding2(x)
              crops = [
                  x[:, :, i : i + scale, :, :]
                  for i in range(
                      0,
                      self.num_frames - scale + scale // 2 * 2,
                      max(scale // 2, 1),
                  )
              ]
          elif scale == 8:
              x = self.replication_padding4(x)
              crops = [
                  x[:, :, i : i + scale, :, :]
                  for i in range(
                      0,
                      self.num_frames - scale + scale // 2 * 2,
                      max(scale // 2, 1),
                  )
              ]
          else:
              crops = [
                  x[:, :, i : i + 1, :, :]
                  for i in range(0, self.num_frames)
              ]
  
          slices = []
          # feature extract with video SwinTransformer
          for crop in crops:
              crop = self.backbone(crop)
              slices.append(crop)
  
          x_scale = torch.cat(
              slices, dim=2
          )  # -> (b, 768, f, size, size)
          x_scale = nn.functional.relu(
              self.bn1(self.conv3d(x_scale))
          )  # -> (b, 512, f, 7, 7)
          x_scale = self.spatial_pooling(
              x_scale
          )  # -> (b, 512, f, 1, 1)
          x_scale = x_scale.squeeze(3).squeeze(3)  # -> (b, 512, f)
          x_scale = x_scale.transpose(1, 2)  # -> (b, f, 512)
  
          # similarity matrix
          x_sims = nn.functional.relu(
              self.sims(x_scale, x_scale, x_scale)
          )  # -> (b, 4, f, f)
          multi_scales.append(x_sims)
  
      x = torch.cat(multi_scales, dim=1)  # -> (B, 4*scale_num, f, f)
      x_matrix = x  # to return matrix
      x = nn.functional.relu(
          self.bn2(self.conv3x3(x))
      )  # -> (b, 32, f, f)
      x = self.dropout1(x)
  
      x = x.permute(0, 2, 3, 1)  # -> (b, f, f, 32)
      x = x.flatten(start_dim=2)  # -> (b, f, 32*f)
      x = nn.functional.relu(self.input_projection(x))  # -> (b, f, 512)
      x = self.ln1(x)
  
      x = x.transpose(0, 1)  # -> (f, b, 512)
      x = self.trans_encoder(x)
      x = x.transpose(0, 1)  # -> (b, f, 512)
  
      x = self.fc(x)  # -> (b, f, 1)
      x = x.squeeze(2)
  
      return x, x_matrix
  
imports: import torch
  from torch import nn
  from towhee.models.layers.transformer_encoder import TransformerEncoder
  from towhee.models.transrac.utils import DenseMap, SimilarityMatrix
label_desc: Use image node_id 2 for calling the TransRAC obj's underlying member method code with example usage: obj.forward(x) and returns: x,  x_matrix