code: def cross_coherence():
      model.eval()
      with torch.no_grad():
          i2t = []
          s2i = []
          gt = []
          for i, dataT in enumerate(test_loader):
              # get the inputs
              images, sentences = unpack_data(dataT, device=device)
              if images.shape[0] != batch_size:
                  break
              _, px_zs, _ = model(
                  [images, sentences], K=1, **forward_args
              )
              cross_sentences = (
                  px_zs[0][1].mean.argmax(dim=-1).squeeze(0)
              )
              cross_images = px_zs[1][0].mean.squeeze(0)
              # calculate correlation with CCA:
              i2t.append(
                  calculate_corr(images, fn_to_emb(cross_sentences))
              )
              s2i.append(
                  calculate_corr(
                      cross_images, fn_to_emb(sentences.int())
                  )
              )
              gt.append(
                  calculate_corr(images, fn_to_emb(sentences.int()))
              )
      print(
          "Coherence score: \nground truth {:10.9f}, \nimage to sentence {:10.9f}, "
          "\nsentence to image {:10.9f}".format(
              sum(gt) / len(gt), sum(i2t) / len(gt), sum(s2i) / len(gt)
          )
      )
  
file_path: mmvae/src/report/analyse_cub.py
imports: import argparse
  import os
  import sys
  import torch
  import torch.nn.functional
  import inspect
  import models
  from utils import Logger, Timer, unpack_data
  from helper import cca, fetch_emb, fetch_weights, fetch_pc, apply_weights, apply_pc
label_desc: Use image node_id 3 for calling a global function with example usage: cross_coherence() without return types