code: def replace_cr_with_newline(message):
      """
      TQDM and requests use carriage returns to get the training line to update for each batch
      without adding more lines to the terminal output.  Displaying those in a file won't work
      correctly, so we'll just make sure that each batch shows up on its one line.
      :param message: the message to permute
      :return: the message with carriage returns replaced with newlines
      """
      if "\r" in message:
          message = message.replace("\r", "")
          if not message or message[-1] != "\n":
              message += "\n"
      return message
  
file_path: magnitude/pymagnitude/third_party/allennlp/common/tee_logger.py
imports: from __future__ import absolute_import
  import os
  from io import open
label_desc: Use image node_id 1 for calling a global function with example usage: replace_cr_with_newline(message) and returns: message