code: def num_tokens_from_string(string: str, model_name=None) -> int:
      """Returns the number of tokens in a text string."""
      global encoding
      if encoding is None:
          from transformers import AutoTokenizer
  
          encoding = AutoTokenizer.from_pretrained(model_name)
      num_tokens = len(encoding.encode(string))
      return num_tokens
  
file_path: h2ogpt/tests/test_long_context.py
imports: import pytest
  from tests.utils import wrap_test_forked
  from src.enums import LangChainAction
  from importlib.metadata import version
  from packaging import version
  import uuid
label_desc: Use image node_id 1 for calling a global function with example usage: num_tokens_from_string(string, model_name) and returns: num_tokens