parameters: (tag: str, np_value: np.ndarray, summary)
docstring: Package the histogram summary.
  
      Args:
          tag (str): Summary tag describe.
          np_value (np.ndarray): Summary data.
          summary (summary_pb2.Summary.Histogram): Summary histogram data.
docstring_summary: Package the histogram summary.
docstring_tokens: Package the histogram summary .
function: def _fill_histogram_summary(tag: str, np_value: np.ndarray, summary) -> None:
      """
      Package the histogram summary.
  
      Args:
          tag (str): Summary tag describe.
          np_value (np.ndarray): Summary data.
          summary (summary_pb2.Summary.Histogram): Summary histogram data.
      """
      logger.debug(f"Set({tag}) the histogram summary value")
      # Default bucket for tensor with no valid data.
      ma_value = np.ma.masked_invalid(np_value)
      total, valid = np_value.size, ma_value.count()
      invalids = []
      for isfn in np.isnan, np.isposinf, np.isneginf:
          if total - valid > sum(invalids):
              invalids.append(np.count_nonzero(isfn(np_value)))
          else:
              invalids.append(0)
  
      summary.count = total
      summary.nan_count, summary.pos_inf_count, summary.neg_inf_count = invalids
      if not valid:
          logger.warning(f'There are no valid values in the ndarray(size={total}, shape={np_value.shape})')
          # summary.{min, max, sum} are 0s by default, no need to explicitly set
      else:
          # BUG: max of a masked array with dtype np.float16 returns inf
          # See numpy issue#15077
          if issubclass(np_value.dtype.type, np.floating):
              summary.min = ma_value.min(fill_value=np.PINF)
              summary.max = ma_value.max(fill_value=np.NINF)
              if summary.min < F32_MIN or summary.max > F32_MAX:
                  logger.warning(f'Values({summary.min}, {summary.max}) are too large, '
                                 f'you may encounter some undefined behaviours hereafter.')
          else:
              summary.min = ma_value.min()
              summary.max = ma_value.max()
          summary.sum = ma_value.sum(dtype=np.float64)
          _fill_bucket(valid, np_value, summary)
function_tokens: def _fill_histogram_summary ( tag : str , np_value : np . ndarray , summary ) -> None : logger . debug ( f"Set({tag}) the histogram summary value" ) # Default bucket for tensor with no valid data. ma_value = np . ma . masked_invalid ( np_value ) total , valid = np_value . size , ma_value . count ( ) invalids = [ ] for isfn in np . isnan , np . isposinf , np . isneginf : if total - valid > sum ( invalids ) : invalids . append ( np . count_nonzero ( isfn ( np_value ) ) ) else : invalids . append ( 0 ) summary . count = total summary . nan_count , summary . pos_inf_count , summary . neg_inf_count = invalids if not valid : logger . warning ( f'There are no valid values in the ndarray(size={total}, shape={np_value.shape})' ) # summary.{min, max, sum} are 0s by default, no need to explicitly set else : # BUG: max of a masked array with dtype np.float16 returns inf # See numpy issue#15077 if issubclass ( np_value . dtype . type , np . floating ) : summary . min = ma_value . min ( fill_value = np . PINF ) summary . max = ma_value . max ( fill_value = np . NINF ) if summary . min < F32_MIN or summary . max > F32_MAX : logger . warning ( f'Values({summary.min}, {summary.max}) are too large, ' f'you may encounter some undefined behaviours hereafter.' ) else : summary . min = ma_value . min ( ) summary . max = ma_value . max ( ) summary . sum = ma_value . sum ( dtype = np . float64 ) _fill_bucket ( valid , np_value , summary )