code: def gather_emb_and_ref(emb, labels, ref_emb=None, ref_labels=None):
      all_emb, all_labels, labels = gather(emb, labels)
      all_ref_emb, all_ref_labels = None, None
  
      if ref_emb is not None:
          all_ref_emb, all_ref_labels, _ = gather(ref_emb, ref_labels)
  
      return all_emb, all_labels, all_ref_emb, all_ref_labels, labels
  
imports: import torch
  from ..losses import BaseMetricLossFunction, CrossBatchMemory
  from ..miners import BaseMiner
  from ..utils import common_functions
  from ..utils import loss_and_miner_utils
label_desc: Use image node_id 5 for calling a global function with example usage: gather_emb_and_ref(emb, labels, ref_emb, ref_labels) and returns: all_emb,  all_labels,  all_ref_emb,  all_ref_labels,  labels