code: import tiktoken
  from llama_index.core import TreeIndex, SimpleDirectoryReader, Settings
  from llama_index.core.llms.mock import MockLLM
  from llama_index.core.callbacks import CallbackManager, TokenCountingHandler
  
  llm = MockLLM(max_tokens=256)
  token_counter = TokenCountingHandler(
      tokenizer=tiktoken.encoding_for_model("gpt-3.5-turbo").encode
  )
  callback_manager = CallbackManager([token_counter])
  
  Settings.callback_manager=callback_manager
  Settings.llm=llm
  
  documents = SimpleDirectoryReader("cost_prediction_samples").load_data()
  
  index = TreeIndex.from_documents(
      documents=documents,
      num_children=2,
      show_progress=True)
  
  print("Total LLM Token Count:", token_counter.total_llm_token_count)
  
  
  
apis: llama_index.core.TreeIndex.from_documents llama_index.core.callbacks.CallbackManager llama_index.core.SimpleDirectoryReader llama_index.core.llms.mock.MockLLM
extract_api: [((219, 242), 'llama_index.core.llms.mock.MockLLM', 'MockLLM', ([], {'max_tokens': '(256)'}), '(max_tokens=256)\n', (226, 242), False, 'from llama_index.core.llms.mock import MockLLM\n'), ((368, 400), 'llama_index.core.callbacks.CallbackManager', 'CallbackManager', (['[token_counter]'], {}), '([token_counter])\n', (383, 400), False, 'from llama_index.core.callbacks import CallbackManager, TokenCountingHandler\n'), ((545, 631), 'llama_index.core.TreeIndex.from_documents', 'TreeIndex.from_documents', ([], {'documents': 'documents', 'num_children': '(2)', 'show_progress': '(True)'}), '(documents=documents, num_children=2, show_progress\n    =True)\n', (569, 631), False, 'from llama_index.core import TreeIndex, SimpleDirectoryReader, Settings\n'), ((475, 523), 'llama_index.core.SimpleDirectoryReader', 'SimpleDirectoryReader', (['"""cost_prediction_samples"""'], {}), "('cost_prediction_samples')\n", (496, 523), False, 'from llama_index.core import TreeIndex, SimpleDirectoryReader, Settings\n'), ((295, 339), 'tiktoken.encoding_for_model', 'tiktoken.encoding_for_model', (['"""gpt-3.5-turbo"""'], {}), "('gpt-3.5-turbo')\n", (322, 339), False, 'import tiktoken\n')]