code: def chunk_docs_in_message(message, chunk_sz):
      if CONST.RETRIEVED_DOCS not in message:
          return message
      new_message = message.copy()
      docs = message[CONST.RETRIEVED_DOCS]
      titles = message.get(CONST.RETRIEVED_DOCS_TITLES)
      urls = message.get(CONST.RETRIEVED_DOCS_URLS)
      new_docs = []
      new_titles = []
      new_urls = []
      checked_sentences = list(
          message.get(
              CONST.SELECTED_SENTENCES,
              message.get(
                  "labels", [CONST.NO_SELECTED_SENTENCES_TOKEN]
              ),
          )
      )
      for i in range(len(checked_sentences)):
          checked_sentences[i] = (
              checked_sentences[i].lstrip(" ").rstrip(" ")
          )
      if (
          " ".join(checked_sentences)
          == CONST.NO_SELECTED_SENTENCES_TOKEN
      ):
          checked_sentences = []
      for ind in range(len(docs)):
          d = docs[ind]
          # Guarantees that checked sentences are not split in half (as we split by space).
          for i in range(len(checked_sentences)):
              d = d.replace(
                  checked_sentences[i], "||CHECKED_SENTENCE_{i}||"
              )
          while True:
              end_chunk = d.find(" ", chunk_sz)
              if end_chunk == -1:
                  # last chunk
                  for i in range(len(checked_sentences)):
                      d = d.replace(
                          "||CHECKED_SENTENCE_{i}||",
                          checked_sentences[i],
                      )
                  new_docs.append(d)
                  new_titles.append(titles[ind])
                  new_urls.append(urls[ind])
                  break
              else:
                  new_d = d[0:end_chunk]
                  for i in range(len(checked_sentences)):
                      new_d = new_d.replace(
                          "||CHECKED_SENTENCE_{i}||",
                          checked_sentences[i],
                      )
                  new_docs.append(new_d)
                  new_titles.append(titles[ind])
                  new_urls.append(urls[ind])
                  d = d[end_chunk + 1 : -1]
      new_message.force_set(CONST.RETRIEVED_DOCS, new_docs)
      new_message.force_set(CONST.RETRIEVED_DOCS_TITLES, new_titles)
      new_message.force_set(CONST.RETRIEVED_DOCS_URLS, new_urls)
      return new_message
  
imports: import torch
  from parlai.core.mutators import register_mutator, MessageMutator, ManyEpisodeMutator
  from typing import Optional
  from parlai.core.opt import Opt
  from parlai.core.message import Message
  from parlai.core.params import ParlaiParser
  import parlai.tasks.wizard_of_internet.constants
  from parlai.tasks.wizard_of_wikipedia.mutators import AddLabel, AddLabelLM, CheckedSentenceAsLabel, AddCheckedSentence
label_desc: Use image node_id 1 for calling a global function with example usage: chunk_docs_in_message(message, chunk_sz) and returns: new_message, message