code: def main():
      # reads the input csv.
      input_csv = pd.read_csv(FLAGS.csv_path)
      if FLAGS.num_shards == -1:
          num_shards = int(math.sqrt(len(input_csv)))
      else:
          num_shards = FLAGS.num_shards
      # Set up the TFRecordWriters.
      basename = os.path.splitext(os.path.basename(FLAGS.csv_path))[0]
      shard_names = [
          os.path.join(
              FLAGS.output_path,
              f"{basename}-{i:05d}-of-{num_shards:05d}",
          )
          for i in range(num_shards)
      ]
      writers = [
          tf.io.TFRecordWriter(shard_name) for shard_name in shard_names
      ]
  
      if FLAGS.shuffle_csv:
          input_csv = input_csv.sample(frac=1)
      with _close_on_exit(writers) as writers:
          for i in tqdm(range(len(input_csv))):
              print(
                  "Processing example %d of %d   (%d%%) \r"
                  % (i, len(input_csv), i * 100 / len(input_csv)),
                  end="",
              )
              if "caption" in input_csv:
                  start = eval(
                      input_csv["start"].values[i]
                  )  # pylint:disable=eval-used
                  end = eval(
                      input_csv["end"].values[i]
                  )  # pylint:disable=eval-used
                  caption = eval(
                      input_csv["caption"].values[i]
                  )  # pylint:disable=eval-used
              else:
                  start = None
                  end = None
                  caption = None
              asr_start = input_csv["asr_start"].values[i]
              if isinstance(asr_start, str):
                  asr_start = eval(
                      asr_start
                  )  # pylint:disable=eval-used
              asr_end = input_csv["asr_end"].values[i]
              if isinstance(asr_end, str):
                  asr_end = eval(asr_end)  # pylint:disable=eval-used
              asr_string = input_csv["asr_string"].values[i]
              if isinstance(asr_string, str):
                  asr_string = eval(
                      asr_string
                  )  # pylint:disable=eval-used
              video_id = input_csv["video_id"].values[i]
              split = None
              if "split" in input_csv:
                  split = input_csv["split"].values[i]
              if isinstance(split, str):
                  split = eval(split)  # pylint:disable=eval-used
              if "features" not in input_csv:  # load on the fly
                  assert FLAGS.features_path
                  features = list(
                      np.load(
                          os.path.join(
                              FLAGS.features_path, video_id + ".npy"
                          )
                      )
                  )
              else:
                  features = eval(
                      input_csv["features"].values[i]
                  )  # pylint:disable=eval-used
              duration = int(input_csv["duration"].values[i])
              seq_ex = generate_sequence_example(
                  video_id,
                  start,
                  end,
                  caption,
                  asr_start,
                  asr_end,
                  asr_string,
                  features,
                  duration,
                  split,
              )
              writers[i % len(writers)].write(
                  seq_ex.SerializeToString()
              )
  
file_path: scenic/scenic/projects/vid2seq/generate_from_file.py
imports: import contextlib
  import math
  import os
  from typing import Optional, Sequence
  from absl import app
  from absl import flags
  import numpy
  import pandas
  import tensorflow
  from tqdm import tqdm
label_desc: Use image node_id 10 for calling a global function with example usage: main() without return types