class_docstr: Correlation
docstr: Build 6-dimensional correlation tensor 
docstr_tok: ["Build","6-dimensional","correlation","tensor"]
code: def compute_crossscale_correlation(
      cls, src_feats, trg_feats, origin_resolution
  ):
      """Build 6-dimensional correlation tensor"""
      eps = 1e-8
  
      bsz, ha, wa, hb, wb = origin_resolution
  
      # Build multiple 4-dimensional correlation tensor
      corr6d = []
      for src_feat in src_feats:
          ch = src_feat.size(1)
          sha, swa = src_feat.size(-2), src_feat.size(-1)
          src_feat = src_feat.view(bsz, ch, -1).transpose(1, 2)
          src_norm = src_feat.norm(p=2, dim=2, keepdim=True)
  
          for trg_feat in trg_feats:
              shb, swb = trg_feat.size(-2), trg_feat.size(-1)
              trg_feat = trg_feat.view(bsz, ch, -1)
              trg_norm = trg_feat.norm(p=2, dim=1, keepdim=True)
  
              corr = torch.bmm(src_feat, trg_feat)
  
              corr_norm = torch.bmm(src_norm, trg_norm) + eps
              corr = corr / corr_norm
  
              correlation = corr.view(
                  bsz, sha, swa, shb, swb
              ).contiguous()
              corr6d.append(correlation)
  
      # Resize the spatial sizes of the 4D tensors to the same size
      for idx, correlation in enumerate(corr6d):
          corr6d[idx] = Geometry.interpolate4d(
              correlation, [ha, wa, hb, wb]
          )
  
      # Build 6-dimensional correlation tensor
      corr6d = (
          torch.stack(corr6d)
          .view(len(src_feats) * len(trg_feats), bsz, ha, wa, hb, wb)
          .transpose(0, 1)
      )
  
      return corr6d.clamp(min=0)
  
file_path: towhee/towhee/models/cvnet/cvnet_block.py
imports: import torch
  from torch import nn
  import torch.nn.functional
  from torch.nn.functional import interpolate
  from towhee.models.layers.conv4d import CenterPivotConv4d
  from towhee.models.cvnet.cvnet_utils import Geometry
  import math
label_desc: Use image node_id 1 for calling the Correlation obj's underlying member method code with example usage: obj.compute_crossscale_correlation(cls, src_feats, trg_feats, origin_resolution) and returns: corr6d