code: def average_checkpoints(last):
      avg = None
      for path in last:
          states = torch.load(
              path, map_location=lambda storage, loc: storage
          )["state_dict"]
          if avg is None:
              avg = states
          else:
              for k in avg.keys():
                  avg[k] += states[k]
      # average
      for k in avg.keys():
          if avg[k] is not None:
              if avg[k].is_floating_point():
                  avg[k] /= len(last)
              else:
                  avg[k] //= len(last)
      return avg
  
imports: import os
  import torch
label_desc: Use image node_id 1 for calling a global function with example usage: average_checkpoints(last) and returns: avg