code: def test_get_formatting_func_from_dataset_with_chatml_messages(self):
      dataset = Dataset.from_dict(
          {
              "messages": [
                  [
                      {"role": "system", "content": "You are helpful"},
                      {"role": "user", "content": "Hello"},
                      {
                          "role": "assistant",
                          "content": "Hi, how can I help you?",
                      },
                  ]
              ]
          }
      )
  
      # Llama tokenizer
      formatting_func = get_formatting_func_from_dataset(
          dataset, self.llama_tokenizer
      )
      self.assertTrue(isinstance(formatting_func, Callable))
      formatted_text = formatting_func(dataset[0])
      self.assertEqual(
          formatted_text,
          "<s>[INST] <<SYS>>\nYou are helpful\n<</SYS>>\n\nHello [/INST] Hi, how can I help you? </s>",
      )
      formatted_text = formatting_func(dataset[0:1])
      self.assertEqual(
          formatted_text,
          [
              "<s>[INST] <<SYS>>\nYou are helpful\n<</SYS>>\n\nHello [/INST] Hi, how can I help you? </s>"
          ],
      )
  
      # ChatML tokenizer
      formatting_func = get_formatting_func_from_dataset(
          dataset, self.chatml_tokenizer
      )
      formatted_text = formatting_func(dataset[0])
      self.assertEqual(
          formatted_text,
          "<|im_start|>system\nYou are helpful<|im_end|>\n<|im_start|>user\nHello<|im_end|>\n<|im_start|>assistant\nHi, how can I help you?<|im_end|>\n",
      )
      formatted_text = formatting_func(dataset[0:1])
      self.assertEqual(
          formatted_text,
          [
              "<|im_start|>system\nYou are helpful<|im_end|>\n<|im_start|>user\nHello<|im_end|>\n<|im_start|>assistant\nHi, how can I help you?<|im_end|>\n"
          ],
      )
  
file_path: trl/tests/test_dataset_formatting.py
imports: import unittest
  from typing import Callable
  from datasets import Dataset, load_dataset
  from transformers import AutoTokenizer
  from trl.extras.dataset_formatting import get_formatting_func_from_dataset
label_desc: Use image node_id 2 for calling the DatasetFormattingTestCase obj's underlying member method code with example usage: obj.test_get_formatting_func_from_dataset_with_chatml_messages() without return types