code: def test_apply_custom_chat_templating_on_chat_message():
      anthropic_template = (
          "{%- for message in messages %}"
          "{%- if message.role == 'user' %}\n\nHuman: {{ message.content.strip() }}"
          "{%- elif message.role == 'assistant' %}\n\nAssistant: {{ message.content.strip() }}"
          "{%- elif message.role == 'function' %}{{ raise('anthropic does not support function calls.') }}"
          "{%- elif message.role == 'system' and loop.index == 1 %}{{ message.content }}"
          "{%- else %}{{ raise('Invalid message role: ' + message.role) }}"
          "{%- endif %}"
          "{%- endfor %}"
          "\n\nAssistant:"
      )
      messages = [
          ChatMessage.from_system("You are good assistant"),
          ChatMessage.from_user("I have a question"),
      ]
      # could be any tokenizer, let's use the one we already likely have in cache
      tokenizer = AutoTokenizer.from_pretrained(
          "HuggingFaceH4/zephyr-7b-beta"
      )
      tokenized_messages = tokenizer.apply_chat_template(
          messages, chat_template=anthropic_template, tokenize=False
      )
      assert (
          tokenized_messages
          == "You are good assistant\nHuman: I have a question\nAssistant:"
      )
  
file_path: haystack/test/dataclasses/test_chat_message.py
imports: import pytest
  from transformers import AutoTokenizer
  from haystack.dataclasses import ChatMessage, ChatRole
label_desc: Use image node_id 7 for calling a global function with example usage: test_apply_custom_chat_templating_on_chat_message() without return types