code: def chars_token_ratio(dataset, tokenizer, nb_examples=400):
      """
      Estimate the average number of characters per token in the dataset.
      """
      total_characters, total_tokens = 0, 0
      for _, example in tqdm(
          zip(range(nb_examples), iter(dataset)), total=nb_examples
      ):
          text = prepare_sample_text(example)
          total_characters += len(text)
          if tokenizer.is_fast:
              total_tokens += len(tokenizer(text).tokens())
          else:
              total_tokens += len(tokenizer.tokenize(text))
  
      return total_characters / total_tokens
  
file_path: trl/examples/research_projects/stack_llama_2/scripts/sft_llama2.py
imports: import os
  from dataclasses import dataclass, field
  from typing import Optional
  import torch
  from accelerate import Accelerator
  from datasets import load_dataset
  from peft import AutoPeftModelForCausalLM, LoraConfig
  from tqdm import tqdm
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, HfArgumentParser, TrainingArguments
  from trl import SFTTrainer
  from trl.import_utils import is_npu_available, is_xpu_available
  from trl.trainer import ConstantLengthDataset
label_desc: Use image node_id 1 for calling a global function with example usage: chars_token_ratio(dataset, tokenizer, nb_examples) and returns: unknown