code: def ref_hist(inp, nbins=64, offset=-48):
      """
      Implement a log2 histogram geared towards visualizing neural net parameters.
  
      Bins are computed as the log2 of the magnitude of a tensor value.  Bins are
      rounded to the nearest int.
  
      Smallest value bin extends to -Inf to enable visualization of zeros.
  
      Log2 computation is always done in fp32 regardless of input dtype to give
      rounding a consistent behavior.
      """
      bins = np.arange(nbins + 1) + float(offset)
      bins[0] = -float("Inf")
      np_inp_log_abs = np.rint(np.log2(np.abs(inp.astype(np.float32))))
      np_hist, edges = np.histogram(
          np_inp_log_abs, density=False, bins=bins
      )
      if np_hist.ndim < 2:
          np_hist = np_hist.reshape(1, np_hist.size)
      return np_hist
  
file_path: neon/tests/test_backend_hist.py
imports: from builtins import str
  import numpy
  import itertools
  import pytest
  from neon.backends.util import check_gpu
  from utils import tensors_allclose
label_desc: Use image node_id 1 for calling a global function with example usage: ref_hist(inp, nbins, offset) and returns: np_hist