code: def ref_binary_weight_affine(
      x, w, wb, alpha, b, base_axis, quantize_zero_to
  ):
      # wb and alpha is the placeholder for the binary weights and scaling factor
      shape = list(x.shape[:base_axis])
      shape += [-1]
      out_shape = w.shape[1:]
  
      # Binarize weights to -1 and 1, and set zeroes to -1
      binw = binarize(w.reshape(w.shape[0], -1), quantize_zero_to)
  
      y = np.dot(x.reshape(*shape), binw)
      if b is not None:
          y += b.reshape((1,) * (len(shape) - 1) + (-1,))
      return y.reshape(tuple(shape[:-1]) + tuple(out_shape))
  
file_path: nnabla/python/test/function/test_binary_weight_affine.py
imports: import pytest
  import numpy
  import nnabla.functions
  from nbla_test_utils import list_context
label_desc: Use image node_id 2 for calling a global function with example usage: ref_binary_weight_affine(x, w, wb, alpha, b, base_axis, quantize_zero_to) and returns: y