code: def create_tfrecords(files, args):
      GPT2TokenizerFast.max_model_input_sizes[
          "gpt2"
      ] = 1e20  # disables a misleading warning
      encoder = GPT2TokenizerFast.from_pretrained("gpt2")
  
      random.seed(args.seed)
  
      all_sequences_across_epochs = []
  
      docs = read_files_to_tokenized_docs(files, args, encoder)
  
      full_seqs, trailing_data = chunk_and_finalize(docs, args, encoder)
  
      all_sequences_across_epochs.extend(full_seqs)
  
      # ep 2+
      for ep_ix in range(1, args.n_repack_epochs):
          # re-shuffle
          if not args.preserve_data_order:
              random.shuffle(docs)
              full_seqs, trailing_data = chunk_and_finalize(
                  docs, args, encoder
              )
          else:
              # if we're preserving data order, we can still "repack" by shifting everything
              # with the trailing data of the last epoch at the beginning
              seqs_with_prefix = [trailing_data] + full_seqs
              full_seqs, trailing_data = chunk_and_finalize(
                  seqs_with_prefix, args, encoder
              )
  
          all_sequences_across_epochs.extend(full_seqs)
  
      # final
      print(f"dropped {len(trailing_data)} tokens of trailing data")
  
      total_sequence_len = len(all_sequences_across_epochs)
  
      fp = os.path.join(
          args.output_dir, f"{args.name}_{total_sequence_len}.tfrecords"
      )
      write_tfrecord(all_sequences_across_epochs, fp)
  
imports: import argparse
  import os
  import re
  import random
  from pathlib import Path
  from typing import List
  import ftfy
  import tensorflow
  from lm_dataformat import Reader
  from transformers import GPT2TokenizerFast
  from tqdm import tqdm
label_desc: Use image node_id 15 for calling a global function with example usage: create_tfrecords(files, args) without return types