code: def check_deltas_swap(root_layer):
      # make sure that the deltas_buffers are
      # swapping back and forth and not using
      # the same allocated memory between layers
      last_buffer = None
      last_layer = None
      for cnt, ll in enumerate(root_layer):
          if cnt == 0:
              # first layer has no deltas
              if type(ll) is not BranchNode:
                  assert ll.deltas is None
              last_layer = ll
              continue
  
          if ll.deltas is not None:
              assert ll.deltas.size >= np.prod(ll.in_shape)
  
          if last_buffer is None:
              # set the last_buffer var if not set yet
              if ll.owns_delta:
                  assert ll.deltas is not None
                  last_buffer = ll.deltas.ptr
              last_layer = ll
              continue
  
          if ll.deltas is not None:
              if type(last_layer) is not BranchNode:
                  assert ll.deltas.ptr != last_buffer
              else:
                  assert ll.deltas.ptr == last_buffer
              last_buffer = ll.deltas.ptr
  
          last_layer = ll
          if issubclass(ll.__class__, Broadcast):
              check_broadcast(ll)
              continue
  
imports: import numpy
  import pytest
  from builtins import zip
  from neon import NervanaObject
  from neon.initializers import Gaussian, Constant, Kaiming
  from neon.layers import GeneralizedCost, Affine, Activation, Dropout
  from neon.layers import Conv, Pooling, Sequential, MergeMultistream
  from neon.layers import MergeSum, SkipNode, BatchNorm, MergeBroadcast, GeneralizedCostMask
  from neon.layers import BranchNode, Multicost, SingleOutputTree, LSTM
  from neon.layers.container import Broadcast
  from neon.models import Model
  from neon.transforms import Rectlin, CrossEntropyBinary, Softmax, Tanh
  from neon.transforms import Logistic, CrossEntropyMulti
label_desc: Use image node_id 2 for calling a global function with example usage: check_deltas_swap(root_layer) without return types