code: def ref_affine(x, w, b, base_axis):
      shape = list(x.shape[:base_axis])
      shape += [-1]
      out_shape = w.shape[1:]
      y = np.dot(x.reshape(*shape), w.reshape(w.shape[0], -1))
      if b is not None:
          y += b.reshape((1,) * (len(shape) - 1) + (-1,))
      return y.reshape(tuple(shape[:-1]) + tuple(out_shape))
  
imports: import pytest
  import numpy
  import nnabla.functions
  from nbla_test_utils import list_context
label_desc: Use image node_id 1 for calling a global function with example usage: ref_affine(x, w, b, base_axis) and returns: y