code: def accumulate_(a, b, size, fn, preserve, step=10000):
      slices = []
      total = 1
      for s in size[:preserve]:
          slices.append(slice(s))
          total *= s
      if step > total:
          return fn(a, b)
  
      ret = torch.zeros(*size, dtype=a.dtype, device=a.device)
  
      a = a.expand(*size[:-2], a.shape[-2], a.shape[-1])
      b = b.expand(*size[:-2], b.shape[-2], b.shape[-1])
  
      a2 = a.contiguous().view(-1, a.shape[-2], a.shape[-1])
      b2 = b.contiguous().view(-1, b.shape[-2], b.shape[-1])
      ret = ret.view(-1, a.shape[-2], b.shape[-1])
      for p in range(0, ret.shape[0], step):
          ret[p : p + step, :] = fn(a2[p : p + step], b2[p : p + step])
      ret = ret.view(*size)
      return ret
  
file_path: pytorch-struct/torch_struct/semirings/checkpoint.py
imports: import torch
label_desc: Use image node_id 7 for calling a global function with example usage: accumulate_(a, b, size, fn, preserve, step) and returns: ret, fn