code: def toks_to_id(
      model: str,
      toks: list[str],
      validation: Optional[list[str]] = None,
  ) -> list[str]:
      if model == "dummy":
          model = "gpt-3.5-turbo"  # pretend it's a chat model
  
      encoder = tiktoken.encoding_for_model(model)
      toks = [encoder.encode(tok) for tok in toks]
      assert all(len(tok) == 1 for tok in toks), f"Invalid toks {toks}"
      toks = [str(tok[0]) for tok in toks]
      if validation:
          assert sorted(toks) == sorted(
              validation
          ), f"Lists are different {toks} {validation}"
      return toks
  
file_path: evals/evals/elsuite/ballots/utils.py
imports: from typing import Optional
  import tiktoken
  from evals.elsuite.ballots.prompts import control_chat_prompt, control_text_template, manipulation_chat_template, manipulation_text_template, text_prompt, voter_chat_prompt, voter_text_prompt
  from evals.registry import is_chat_model
label_desc: Use image node_id 1 for calling a global function with example usage: toks_to_id(model, toks, validation) and returns: toks