def _clean_tag(name):
<EOL>if name is not None:<EOL><INDENT>new_name = _INVALID_TAG_CHARACTERS.sub('<STR_LIT:_>', name)<EOL>new_name = new_name.lstrip('<STR_LIT:/>')  <EOL>if new_name != name:<EOL><INDENT>logging.warning('<STR_LIT>', name, new_name)<EOL>name = new_name<EOL><DEDENT><DEDENT>return name<EOL>
Cleans a tag. Removes illegal characters for instance.
    Adapted from the TensorFlow function `clean_tag()` at
    https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/summary_op_util.py

    Parameters
    ----------
        name : str
            The original tag name to be processed.

    Returns
    -------
        The cleaned tag name.