code: def test_all_rand(backend_default, allrand_args, deltas_buffer):
      # test with random weights and random inputs
      dtypeu = np.float32
      w_rng, rngmax = allrand_args
      inp_rng = [0.0, rngmax]
      nin = 1024
      nout = 2048
      batch_size = 16
      NervanaObject.be.bsz = batch_size
  
      init_unif = Uniform(low=w_rng[0], high=w_rng[1])
      layer = Linear(nout=nout, init=init_unif)
      inp = np.random.random((nin, batch_size))
      inp *= inp_rng[1] - inp_rng[0]
      inp += inp_rng[0]
      inp = inp.astype(dtypeu)
      layer.configure(nin)
      layer.prev_layer = True  # Hack to force delta buffer allocation
      layer.allocate()
  
      layer.allocate_deltas(deltas_buffer)
      deltas_buffer.allocate_buffers()
      layer.set_deltas(deltas_buffer)
  
      out = layer.fprop(layer.be.array(inp)).get()
      w = layer.W.get()
  
      # the expected output using numpy
      out_exp = np.dot(w, inp)
  
      # for larger layers need to estimate numerical precision
      atol = 2 * est_mm_prec(w, inp, ntrials=1)
      assert allclose_with_out(
          out_exp, out, atol=atol, rtol=0.0
      ), "%e %e" % (np.max(np.abs(out - out_exp)), atol)
  
      err = np.random.random((nout, batch_size))
      err = err * (inp_rng[1] - inp_rng[0]) + inp_rng[0]
      err = err.astype(dtypeu)
      deltas = layer.bprop(layer.be.array(err)).get()
      dw = layer.dW.get()
  
      deltas_exp = np.dot(w.T, err)
      atol = 2 * est_mm_prec(w.T, err, ntrials=1)
      assert allclose_with_out(
          deltas_exp, deltas, atol=atol, rtol=0.0
      ), "%e %e" % (np.max(np.abs(deltas_exp - deltas)), atol)
  
      dw_exp = np.dot(err, inp.T)
      atol = 2 * est_mm_prec(err, inp.T, ntrials=1)
      assert allclose_with_out(
          dw_exp, dw, atol=atol, rtol=0.0
      ), "%e %e" % (np.max(np.abs(dw_exp - dw)), atol)
  
      return
  
file_path: neon/tests/test_linear_layer.py
imports: import itertools
  import numpy
  from neon import NervanaObject
  from neon.initializers.initializer import Uniform
  from neon.layers.layer import Linear
  from utils import allclose_with_out
label_desc: Use image node_id 4 for calling a global function with example usage: test_all_rand(backend_default, allrand_args, deltas_buffer) without return types