code: def test_histogram_execution(setup):
      rs = np.random.RandomState(0)
  
      raw = rs.randint(10, size=(20,))
      a = tensor(raw, chunk_size=6)
      raw_weights = rs.random(20)
      weights = tensor(raw_weights, chunk_size=8)
  
      # range provided
      for range_ in [(0, 10), (3, 11), (3, 7)]:
          bin_edges = histogram(a, range=range_)[0]
          result = bin_edges.execute().fetch()
          expected = np.histogram(raw, range=range_)[0]
          np.testing.assert_array_equal(result, expected)
  
      for wt in (raw_weights, weights):
          for density in (True, False):
              bins = [1, 4, 6, 9]
              bin_edges = histogram(
                  a, bins=bins, weights=wt, density=density
              )[0]
              result = bin_edges.execute().fetch()
              expected = np.histogram(
                  raw, bins=bins, weights=raw_weights, density=density
              )[0]
              np.testing.assert_almost_equal(result, expected)
  
      raw2 = rs.randint(10, size=(1,))
      b = tensor(raw2)
      raw3 = rs.randint(10, size=(0,))
      c = tensor(raw3)
      for t, r in [(a, raw), (b, raw2), (c, raw3), (sort(a), raw)]:
          for density in (True, False):
              test_bins = [
                  10,
                  "stone",
                  "auto",
                  "doane",
                  "fd",
                  "rice",
                  "scott",
                  "sqrt",
                  "sturges",
              ]
              for bins in test_bins:
                  hist = histogram(t, bins=bins, density=density)[0]
                  result = hist.execute().fetch()
                  expected = np.histogram(
                      r, bins=bins, density=density
                  )[0]
                  np.testing.assert_array_equal(result, expected)
  
              test_bins = [[0, 4, 8], tensor([0, 4, 8], chunk_size=2)]
              for bins in test_bins:
                  hist = histogram(t, bins=bins, density=density)[0]
                  result = hist.execute().fetch()
                  expected = np.histogram(
                      r, bins=[0, 4, 8], density=density
                  )[0]
                  np.testing.assert_array_equal(result, expected)
  
          # test unknown shape
          raw4 = rs.rand(10)
          d = tensor(raw4, chunk_size=6)
          d = d[d < 0.9]
          hist = histogram(d)
          result = hist.execute().fetch()[0]
          expected = np.histogram(raw4[raw4 < 0.9])[0]
          np.testing.assert_array_equal(result, expected)
  
          raw5 = np.arange(3, 10)
          e = arange(10, chunk_size=6)
          e = e[e >= 3]
          hist = histogram(e)
          result = hist.execute().fetch()[0]
          expected = np.histogram(raw5)[0]
          np.testing.assert_array_equal(result, expected)
  
imports: import numpy
  import scipy.sparse
  import pytest
  from ....utils import ignore_warning
  from ...datasource import arange, tensor, empty
  from ...base import sort
  from ...merge import stack
  from ...reduction import all
  from ..None import average, bincount, cov, corrcoef, ptp, digitize, histogram_bin_edges, histogram, quantile, percentile, median
  from ..quantile import INTERPOLATION_TYPES
label_desc: Use image node_id 7 for calling a global function with example usage: test_histogram_execution(setup) without return types