code: def replace_cr_with_newline(message: str) -> str:
      """
      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.
      """
      # In addition to carriage returns, nested progress-bars will contain extra new-line
      # characters and this special control sequence which tells the terminal to move the
      # cursor one line up.
      message = (
          message.replace("\r", "").replace("\n", "").replace("[A", "")
      )
      if message and message[-1] != "\n":
          message += "\n"
      return message
  
file_path: allennlp/allennlp/common/tqdm.py
imports: import logging
  from allennlp.common import logging
  import sys
  from time import time
  from typing import Optional
label_desc: Use image node_id 1 for calling a global function with example usage: replace_cr_with_newline(message) and returns: message