code: def preprocess_cpmbee(example, prompter, tokenizer, options):
      # data = {"prompt": example["instruction"], "input": example["input"], "<ans>": example["output"]}
      data = {
          "input": example["instruction"] + "\n" + example["input"],
          "<ans>": example["output"],
      }
      raw_data = {}
      (
          input_ids,
          input_id_subs,
          context,
          segment_ids,
          segment_rel,
          n_segments,
          _,
      ) = tokenizer.convert_data_to_id(data)
      input_ids = input_ids[: options.cutoff_len]
      input_id_subs = input_id_subs[: options.cutoff_len]
      context = context[: options.cutoff_len]
      segment_ids = segment_ids[: options.cutoff_len]
      raw_data["input"] = data
      raw_data["samples"] = []
      sample_ids = np.zeros(input_ids.shape, dtype=np.int32)
      segment_rel_offset = np.zeros(input_ids.shape, dtype=np.int32)
      num_segments = np.full(
          input_ids.shape, n_segments, dtype=np.int32
      )
  
      return {
          "input_ids": input_ids,
          "inputs_sub": input_id_subs,
          "context": context,
          "sample_ids": sample_ids,
          "segments": segment_ids,
          "num_segments": num_segments,
          "segment_rel_offset": segment_rel_offset,
          "segment_rel": segment_rel,
          "spans": [input_ids.shape[0]],
          "raw_data": raw_data,
      }
  
file_path: DeepKE/example/llm/InstructKGC/src/datamodule/cpmbee.py
imports: from dataclasses import dataclass
  import numpy
  from transformers import PreTrainedTokenizerBase
  from transformers.tokenization_utils_base import BatchEncoding
  from numpy.typing import NDArray
  from typing import Any, Dict, List, Tuple
label_desc: Use image node_id 1 for calling a global function with example usage: preprocess_cpmbee(example, prompter, tokenizer, options) and returns: dict