code: def test_carriage_return():
      def through(xs):
          buf = io.StringIO()
          f = ut.TqdmFile(file=buf)
  
          for x in xs:
              f.write(x)
              f.flush()
  
          return buf.getvalue()
  
      # Strings pass through tqdmfile with no newline attached.
      assert through(["Yo!"]) == "Yo!"
  
      # Empty lines do nothing.
      assert through(["", "", ""]) == ""
  
      # A carriage return is converted to a newline, but the next line, if it's
      # written, will have the proper prefix to trigger a carriage return.
      assert through(["Yo!\r"]) == "Yo!\n"
  
      # Boom, triggered.
      assert (
          through(["Yo!\r", "continue"])
          == f"Yo!\n{_term_move_up()}\rcontinue"
      )
  
imports: import io
  from tqdm.utils import _term_move_up
  import caliban.util.tqdm
label_desc: Use image node_id 1 for calling a global function with example usage: test_carriage_return() and returns: buf