code: def train_simple_encoding():
      gpt2_pattern = r"""'s|'t|'re|'ve|'m|'ll|'d| ?[\p{L}]+| ?[\p{N}]+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+"""
      with open(__file__, "r") as f:
          data = f.read()
  
      enc = SimpleBytePairEncoding.train(
          data, vocab_size=600, pat_str=gpt2_pattern
      )
  
      print(
          "This is the sequence of merges performed in order to encode 'hello world':"
      )
      tokens = enc.encode("hello world")
      assert enc.decode(tokens) == "hello world"
      assert enc.decode_bytes(tokens) == b"hello world"
      assert enc.decode_tokens_bytes(tokens) == [b"hello", b" world"]
  
      return enc
  
file_path: tiktoken/tiktoken/_educational.py
imports: import collections
  from typing import Optional
  import regex
  import tiktoken
label_desc: Use image node_id 4 for calling a global function with example usage: train_simple_encoding() and returns: enc