code: def _check_histogram(
      self, arrays, num_bins, expected_values=None, expected_counts=None
  ):
      # Check that sizes match and counts add up.
      values = workspace.FetchBlob("histogram_values")
      counts = workspace.FetchBlob("histogram_counts")
      self.assertTrue(np.size(values) == num_bins)
      self.assertTrue(np.size(counts) == num_bins)
      self.assertTrue(
          np.sum(counts) == sum([np.size(array) for array in arrays])
      )
  
      # Check counts
      if expected_counts is None:
          # Check that counts are correct for the returned values if expected_counts is not given.
          expected_counts = np.zeros(num_bins, dtype="i")
          for array in arrays:
              for input_val in array:
                  input_val = abs(input_val) if self.abs else input_val
                  found = False
                  for pos in range(np.size(values)):
                      if values[pos] > input_val:
                          found = True
                          break
                  self.assertTrue(
                      found,
                      f"input value must fit inside values array: "
                      f"input={input_val}, last_value={values[-1]}",
                  )
                  if self.bin_spacing == "linear":
                      self.assertTrue(
                          pos > 0,
                          f"input should not be smaller than the first bin value: "
                          f"input={input_val}, 1st bin value={values[pos]}",
                      )
                  if pos == 0:
                      self.assertEqual(self.bin_spacing, "logarithmic")
                      expected_counts[pos] += 1
                  else:
                      expected_counts[pos - 1] += 1
      self.assertTrue(
          np.array_equal(expected_counts, counts),
          f"expected:{expected_counts}\ncounts:{counts}",
      )
      # Check values
      if expected_values is not None:
          self.assertTrue(
              np.allclose(
                  expected_values, values, rtol=1e-02, atol=1e-05
              ),
              f"expected:{expected_values}\nvalues:{values}",
          )
      # Ideally, the output values are sorted in a non-decreasing order.
      for idx in range(len(values) - 1):
          self.assertTrue(values[idx] <= values[idx + 1])
      if self.abs:
          self.assertTrue(values[0] >= 0)
  
imports: import unittest
  import caffe2.python.hypothesis_test_util
  import hypothesis.strategies
  import numpy
  from caffe2.python import core, workspace
  from hypothesis import given, settings
label_desc: Use image node_id 2 for calling the TestSelfBinningHistogramBase obj's underlying member method code with example usage: obj._check_histogram(arrays, num_bins, expected_values, expected_counts) without return types