code: def collect_fn(all_mat):
      def fn(mat, *_):
          all_mat.append(mat)
  
      return fn
  
imports: import unittest
  import torch
  from pytorch_metric_learning.distances import BatchedDistance, CosineSimilarity
label_desc: Use image node_id 1 for calling a global function with example usage: collect_fn(all_mat) and returns: fn