code: def test_crdedupe_process_chunks():
      fp = CRDedupeFilePolicy()
      sep = os.linesep
      files = {"output.log": None}
  
      # Test STDERR progress bar updates (\r lines) overwrite the correct offset.
      # Test STDOUT and STDERR normal messages get appended correctly.
      chunks = [
          Chunk(data=f"timestamp text{sep}"),
          Chunk(data=f"ERROR timestamp error message{sep}"),
          Chunk(data=f"ERROR timestamp progress bar{sep}"),
          Chunk(data=f"ERROR timestamp \rprogress bar update 1{sep}"),
          Chunk(data=f"ERROR timestamp \rprogress bar update 2{sep}"),
          Chunk(data=f"timestamp text{sep}text{sep}text{sep}"),
          Chunk(data=f"ERROR timestamp error message{sep}"),
      ]
      ret = fp.process_chunks(chunks)
      want = [
          {
              "offset": 0,
              "content": [
                  "timestamp text\n",
                  "ERROR timestamp error message\n",
                  "ERROR timestamp progress bar update 2\n",
                  "timestamp text\n",
                  "timestamp text\n",
                  "timestamp text\n",
                  "ERROR timestamp error message\n",
              ],
          }
      ]
      print(f"\n{ret}")
      print(want)
      assert ret == want
      files["output.log"] = ret
      file_requests = list(
          split_files(files, max_bytes=util.MAX_LINE_BYTES)
      )
      assert 1 == len(file_requests)
  
      # Test that STDERR progress bar updates in next list of chunks still
      # maps to the correct offset.
      # Test that we can handle STDOUT progress bars (\r lines) as well.
      chunks = [
          Chunk(data=f"ERROR timestamp \rprogress bar update 3{sep}"),
          Chunk(data=f"ERROR timestamp \rprogress bar update 4{sep}"),
          Chunk(data=f"timestamp \rstdout progress bar{sep}"),
          Chunk(data=f"timestamp text{sep}"),
          Chunk(data=f"timestamp \rstdout progress bar update{sep}"),
      ]
      ret = fp.process_chunks(chunks)
      want = [
          {
              "offset": 2,
              "content": ["ERROR timestamp progress bar update 4\n"],
          },
          {
              "offset": 5,
              "content": ["timestamp stdout progress bar update\n"],
          },
          {"offset": 7, "content": ["timestamp text\n"]},
      ]
      print(f"\n{ret}")
      print(want)
      assert ret == want
      files["output.log"] = ret
      file_requests = list(
          split_files(files, max_bytes=util.MAX_LINE_BYTES)
      )
      assert 3 == len(file_requests)
  
      # Test that code handles final progress bar output and correctly
      # offsets any new progress bars.
      chunks = [
          Chunk(data=f"timestamp text{sep}"),
          Chunk(
              data=f"ERROR timestamp \rprogress bar final{sep}text{sep}text{sep}"
          ),
          Chunk(data=f"ERROR timestamp error message{sep}"),
          Chunk(data=f"ERROR timestamp new progress bar{sep}"),
          Chunk(
              data=f"ERROR timestamp \rnew progress bar update 1{sep}"
          ),
      ]
      ret = fp.process_chunks(chunks)
      want = [
          {
              "offset": 2,
              "content": ["ERROR timestamp progress bar final\n"],
          },
          {
              "offset": 8,
              "content": [
                  "timestamp text\n",
                  "ERROR timestamp text\n",
                  "ERROR timestamp text\n",
                  "ERROR timestamp error message\n",
                  "ERROR timestamp new progress bar update 1\n",
              ],
          },
      ]
      print(f"\n{ret}")
      print(want)
      assert ret == want
      files["output.log"] = ret
      file_requests = list(
          split_files(files, max_bytes=util.MAX_LINE_BYTES)
      )
      assert 2 == len(file_requests)
  
file_path: wandb/tests/pytest_tests/unit_tests/test_file_stream.py
imports: import itertools
  import os
  import random
  import string
  from dataclasses import dataclass
  from wandb import util
  from wandb.sdk.internal.file_stream import CRDedupeFilePolicy
  from wandb.sdk.lib.file_stream_utils import split_files
label_desc: Use image node_id 4 for calling a global function with example usage: test_crdedupe_process_chunks() without return types