docs: def write(histogram):
      """Convert a histogram to a protobuf message.
  
      Note: Currently, all binnings are converted to
        static form. When you load the histogram again,
        you will lose any related behaviour.
  
      Note: A histogram collection is also planned.
      
      Parameters
      ----------
      histogram : HistogramBase | list | dict
          Any histogram
  
      Returns
      -------
      message : google.protobuf.message.Message
          A protocol buffer message
      """
      
      histogram_dict = histogram.to_dict()
      message = Histogram()
  
      for field in SIMPLE_CONVERSION_FIELDS:
          setattr(message, field, histogram_dict[field])
  
      # Main numerical data - TODO: Optimize!
      message.frequencies.extend(histogram.frequencies.flatten())
      message.errors2.extend(histogram.errors2.flatten())
  
      # Binnings
      for binning in histogram._binnings:
          binning_message = message.binnings.add()
          for edges in binning.bins:
              limits = binning_message.bins.add()
              limits.lower = edges[0]
              limits.upper = edges[1]
  
      # All meta data
      meta_message = message.meta
      # user_defined = {}
      # for key, value in histogram.meta_data.items():
      #     if key not in PREDEFINED:
      #         user_defined[str(key)] = str(value)
      for key in SIMPLE_META_KEYS:
          if key in histogram.meta_data:
              setattr(meta_message, key, str(histogram.meta_data[key]))
      if "axis_names" in histogram.meta_data:
          meta_message.axis_names.extend(histogram.meta_data["axis_names"])
  
      message.physt_version = CURRENT_VERSION
      message.physt_compatible = COMPATIBLE_VERSION
      return message