# Path: tensorboardX/summary.py
# def _clean_tag(name):
#     # In the past, the first argument to summary ops was a tag, which allowed
#     # arbitrary characters. Now we are changing the first argument to be the node
#     # name. This has a number of advantages (users of summary ops now can
#     # take advantage of the tf name scope system) but risks breaking existing
#     # usage, because a much smaller set of characters are allowed in node names.
#     # This function replaces all illegal characters with _s, and logs a warning.
#     # It also strips leading slashes from the name.
#     if name is not None:
#         new_name = _INVALID_TAG_CHARACTERS.sub('_', name)
#         new_name = new_name.lstrip('/')  # Remove leading slashes
#         if new_name != name:
#             logging.info(
#                 'Summary name %s is illegal; using %s instead.' % (name, new_name))
#             name = new_name
#     return name


import logging
import json
import functools
import numpy as np
    import comet_ml
from io import BytesIO
from google.protobuf.json_format import MessageToJson
from .summary import _clean_tag
    from PIL import Image
        histogram_proto = summary.value[0].histo
        histogram_raw_data = MessageToJson(histogram_proto)
        histogram_raw_data['name'] = tag

        self.log_asset_data(data=histogram_raw_data, name=tag, step=step)

    @_requiresComet
    def log_curve(self, name, x, y, overwrite=False, step=None):
        """Log timeseries data.

        Args:
        name: (str) name of data
        x: array of x-axis values
        y: array of y-axis values
        overwrite: (optional, bool) if True, overwrite previous log
        step: (optional, int) the step value
        """
        self._experiment.log_curve(name, x.tolist(), y.tolist(), overwrite, step)

    @_requiresComet
    def log_image_encoded(self, encoded_image_string, tag, step=None):
        """Logs the image. Images are displayed on the Graphics tab on Comet.ml.

        Args:
        encoded_image_string: Required. An encoded image string
        tag: String - Data identifier
        step: Optional. Used to associate the image asset to a specific step.
        """
        buff = BytesIO(encoded_image_string)
        image_pil = Image.open(buff)

# Path: tensorboardX/summary.py
# def _clean_tag(name):
#     # In the past, the first argument to summary ops was a tag, which allowed
#     # arbitrary characters. Now we are changing the first argument to be the node
#     # name. This has a number of advantages (users of summary ops now can
#     # take advantage of the tf name scope system) but risks breaking existing
#     # usage, because a much smaller set of characters are allowed in node names.
#     # This function replaces all illegal characters with _s, and logs a warning.
#     # It also strips leading slashes from the name.
#     if name is not None:
#         new_name = _INVALID_TAG_CHARACTERS.sub('_', name)
#         new_name = new_name.lstrip('/')  # Remove leading slashes
#         if new_name != name:
#             logging.info(
#                 'Summary name %s is illegal; using %s instead.' % (name, new_name))
#             name = new_name
#     return name


# Path: tensorboardX/comet_utils.py
import logging
import json
import functools
import numpy as np
    import comet_ml
from io import BytesIO
from google.protobuf.json_format import MessageToJson
from .summary import _clean_tag
    from PIL import Image

        histogram_proto = summary.value[0].histo
        histogram_raw_data = MessageToJson(histogram_proto)
        histogram_raw_data['name'] = tag

        self.log_asset_data(data=histogram_raw_data, name=tag, step=step)

    @_requiresComet
    def log_curve(self, name, x, y, overwrite=False, step=None):
        """Log timeseries data.

        Args:
        name: (str) name of data
        x: array of x-axis values
        y: array of y-axis values
        overwrite: (optional, bool) if True, overwrite previous log
        step: (optional, int) the step value
        """
        self._experiment.log_curve(name, x.tolist(), y.tolist(), overwrite, step)

    @_requiresComet
    def log_image_encoded(self, encoded_image_string, tag, step=None):
        """Logs the image. Images are displayed on the Graphics tab on Comet.ml.

        Args:
        encoded_image_string: Required. An encoded image string
        tag: String - Data identifier
        step: Optional. Used to associate the image asset to a specific step.
        """
        buff = BytesIO(encoded_image_string)
        image_pil = Image.open(buff)

        name = _clean_tag(tag)