code: def load_tokenize_data(args):
      # Load and tokenize data
      if os.path.exists(args.cache_data):
          train_data = load_from_disk(args.cache_data)
          print(f"  ==> Loaded {len(train_data)} samples")
          return train_data
      else:
          datasets = load_dataset(
              "json", data_files=args.instruct_data_path
          )["train"]
          tokenizer = AutoTokenizer.from_pretrained(args.load)
  
          def preprocess_function(examples):
              prompt_input, prompt_no_input = (
                  PROMPT_DICT["prompt_input"],
                  PROMPT_DICT["prompt_no_input"],
              )
              source = [
                  prompt_input.format_map(
                      {"instruction": instruct, "input": inp}
                  )
                  if inp != ""
                  else prompt_no_input.format_map(
                      {"instruction": instruct}
                  )
                  for instruct, inp in zip(
                      examples["instruction"], examples["input"]
                  )
              ]
              target = [
                  src + output + tokenizer.eos_token
                  for src, output in zip(source, examples["output"])
              ]
  
              model_inputs = tokenizer(
                  source,
                  max_length=args.max_len,
                  padding="max_length",
                  truncation=True,
              )
              labels = tokenizer(
                  target,
                  max_length=args.max_len,
                  padding="max_length",
                  truncation=True,
              )
              model_inputs["decoder_input_ids"] = copy.deepcopy(
                  labels["input_ids"]
              )
  
              # changing labels: convert all tokens in the duplicate prefix prompt and the padding part to -100
              eos_token_id = tokenizer.eos_token_id
              for x, y in zip(
                  model_inputs["input_ids"], labels["input_ids"]
              ):
                  label_prefix_len = (
                      x.index(eos_token_id)
                      if eos_token_id in x
                      else len(x)
                  )
                  y[:label_prefix_len] = [-100] * label_prefix_len
  
                  if eos_token_id in y:
                      pad_len = len(y) - y.index(eos_token_id) - 1
                      if pad_len > 0:
                          y[y.index(eos_token_id) + 1 :] = [
                              -100
                          ] * pad_len
  
              # shift labels to the right as the decoder input and add decoder start token id
              decoder_start_id = tokenizer.eos_token_id
              for z in model_inputs["decoder_input_ids"]:
                  z[1:] = z[:-1]
                  z[0] = decoder_start_id
  
              model_inputs["labels"] = copy.deepcopy(
                  labels["input_ids"]
              )
              model_inputs["decoder_attention_mask"] = labels[
                  "attention_mask"
              ]
              return model_inputs
  
          train_data = datasets.map(
              preprocess_function,
              batched=True,
              remove_columns=datasets.column_names,
              num_proc=64,
              load_from_cache_file=False,
          )
  
          print(f"  ==> Loaded {len(train_data)} samples")
          train_data.save_to_disk(args.cache_data)
          print(f"  ==> Saved to {args.cache_data}")
          return train_data
  
file_path: codet5/CodeT5+/instruct_tune_codet5p.py
imports: import os
  import pprint
  import argparse
  import numpy
  import copy
  import torch
  from datasets import load_dataset, load_from_disk
  from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, TrainingArguments, Trainer
label_desc: Use image node_id 4 for calling a global function with example usage: load_tokenize_data(args) and returns: train_data, train_data, model_inputs