class_docstr: - Use ROUGE-2 as [PaLM 2](https://ai.google/static/documents/palm2techreport.pdf)
  - Use Mecab tokenizer for Japanese eval
code: def preprocess_ctx(
      self, ctx, max_length, ctx_prompt="ニュース記事:", summary_prompt="要約:"
  ):
      if len(self._tokenize(ctx)) <= max_length:
          return ctx
      # if the inputs too long, truncate inputs
      ctxs = [f"{ctx_prompt}{c}" for c in ctx.split(ctx_prompt)]
      description = ""
      if summary_prompt not in ctxs[0]:
          description = ctxs[0].replace(ctx_prompt, "")
          ctxs = ctxs[1:]
      max_length_per_shot = max_length // len(ctxs)
      res = description
      for c in ctxs:
          text, summary = c.split(summary_prompt)
          sentences = text.split("。")
          c_res = ""
          add_sentences = []
          for s in sentences:
              tmp = add_sentences + [s]
              if (
                  len(self._tokenize(text="。".join(tmp)))
                  > max_length_per_shot
              ):
                  if len(add_sentences) > 0:
                      add_sentences[-1] += "。" + self.SEP
                  else:
                      # I believe this case does't happen. But, let's make sure to avoid IndexError
                      # In this case, just truncate the first sentence
                      token_ids = self._tokenize(s)[
                          :max_length_per_shot
                      ]
                      truncated_s = self.tokenizer.decode(
                          token_ids, skip_special_tokens=True
                      )
                      add_sentences.append(truncated_s + self.SEP)
                  break
              add_sentences.append(s)
          c_res += "。".join(add_sentences)
          res += f"{c_res}{summary_prompt}{summary}"
      return res
  
imports: import os
  import inspect
  from lm_eval.utils import rouge2_mecab
  from lm_eval.base import rf, Task
label_desc: Use image node_id 10 for calling the XLSumJa obj's underlying member method code with example usage: obj.preprocess_ctx(ctx, max_length, ctx_prompt, summary_prompt) and returns: res, ctx