code: def _count_reduce_items(arr, axis, keepdims=False, where=True):
      # fast-path for the default case
      if where is True:
          # no boolean mask given, calculate items according to axis
          if axis is None:
              axis = tuple(range(arr.ndim))
          elif not isinstance(axis, tuple):
              axis = (axis,)
          items = 1
          for ax in axis:
              items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)]
          items = nt.intp(items)
      else:
          # TODO: Optimize case when `where` is broadcast along a non-reduction
          # axis and full sum is more excessive than needed.
  
          # guarded to protect circular imports
          from numpy.lib.stride_tricks import broadcast_to
  
          # count True values in (potentially broadcasted) boolean mask
          items = umr_sum(
              broadcast_to(where, arr.shape),
              axis,
              nt.intp,
              None,
              keepdims,
          )
      return items
  
imports: import warnings
  from contextlib import nullcontext
  from numpy.core import multiarray
  from numpy.core import umath
  from numpy.core.multiarray import asanyarray
  from numpy.core import numerictypes
  from numpy.core import _exceptions
  from numpy.core._ufunc_config import _no_nep50_warning
  from numpy._globals import _NoValue
  from numpy.compat import pickle, os_fspath
label_desc: Use image node_id 7 for calling a global function with example usage: _count_reduce_items(arr, axis, keepdims, where) and returns: items