code: def profile_fraction_of_true(bin_labels, bin_counts):
      """Compute fraction of 'true' labels
  
      :param bin_labels: Array containing numbers whose mean is desired. If `a` is not an
          array, a conversion is attempted.
      :param bin_entries: Array containing weights for the elements of `a`. If `weights` is not an
          array, a conversion is attempted.
      :return: fraction of 'true' labels
      """
      bin_labels = np.array(bin_labels)
      bin_entries = np.array(bin_counts)
      assert len(bin_labels) == len(bin_entries)
  
      def replace(bl):
          if bl in {"True", "true"}:
              return True
          elif bl in {"False", "false"}:
              return False
          return np.nan
  
      # basic checks: dealing with boolean labels
      # also accept strings of 'True' and 'False'
      if (
          len(bin_labels) == 0
          or len(bin_labels) > 4
          or np.sum(bin_entries) == 0
      ):
          return np.nan
      if not np.all(
          [isinstance(bl, (bool, np.bool_)) for bl in bin_labels]
      ):
          if not np.all(
              [
                  isinstance(bl, (str, np.str_, np.string_))
                  for bl in bin_labels
              ]
          ):
              return np.nan
          # all strings from hereon
          n_true = (bin_labels == "True").sum() + (
              bin_labels == "true"
          ).sum()
          n_false = (bin_labels == "False").sum() + (
              bin_labels == "false"
          ).sum()
          n_nan = (
              (bin_labels == "NaN").sum()
              + (bin_labels == "nan").sum()
              + (bin_labels == "None").sum()
              + (bin_labels == "none").sum()
              + (bin_labels == "Null").sum()
              + (bin_labels == "null").sum()
          )
          if n_true + n_false + n_nan != len(bin_labels):
              return np.nan
          # convert string to boolean
          bin_labels = np.array([replace(bl) for bl in bin_labels])
  
      sum_true = np.sum(
          [be for bl, be in zip(bin_labels, bin_entries) if bl]
      )
      sum_false = np.sum(
          [be for bl, be in zip(bin_labels, bin_entries) if not bl]
      )
      sum_entries = sum_true + sum_false
      if sum_entries == 0:
          # all nans scenario
          return np.nan
      # exclude nans from fraction
      return (1.0 * sum_true) / sum_entries
  
file_path: popmon/popmon/analysis/profiling/profiles.py
imports: import numpy
  from popmon.analysis.hist_numpy import get_2dgrid
  from popmon.base.registry import Registry
  from popmon.hist.hist_utils import sum_entries
  from popmon.stats import numpy
label_desc: Use image node_id 12 for calling a global function with example usage: profile_fraction_of_true(bin_labels, bin_counts) and returns: unknown, np, np, np, True, np, np, False