code: def save_split_sharded_dataset(
      dataset, path_save_dir_sharded_dataset, shard_size
  ):
      os.makedirs(path_save_dir_sharded_dataset, exist_ok=True)
  
      f = open(
          os.path.join(
              path_save_dir_sharded_dataset, "dataset_dict.json"
          ),
          "w",
      )
      f.write('{"splits": ["train", "valid"]}')
      f.close()
  
      os.makedirs(
          os.path.join(path_save_dir_sharded_dataset, "train"),
          exist_ok=True,
      )
      os.makedirs(
          os.path.join(path_save_dir_sharded_dataset, "valid"),
          exist_ok=True,
      )
  
      logger.info("Starting sharding the dataset")
  
      num_shards = math.ceil(len(dataset) / shard_size)
      for idx in tqdm(range(num_shards)):
          shard = dataset.shard(
              num_shards=num_shards, index=idx, contiguous=True
          )
          if idx < 2:
              shard.save_to_disk(
                  os.path.join(
                      path_save_dir_sharded_dataset,
                      "valid",
                      f"shard_{idx}",
                  )
              )
          else:
              shard.save_to_disk(
                  os.path.join(
                      path_save_dir_sharded_dataset,
                      "train",
                      f"shard_{idx}",
                  )
              )
  
      logger.info("Finished sharding the dataset")
  
imports: import glob
  import json
  import logging
  import math
  import os
  import tarfile
  from copy import deepcopy
  import git
  from datasets import Dataset, Image, Sequence, Value, concatenate_datasets, load_from_disk
  from pathos.multiprocessing import ProcessingPool
  from tqdm import tqdm
label_desc: Use image node_id 9 for calling a global function with example usage: save_split_sharded_dataset(dataset, path_save_dir_sharded_dataset, shard_size) without return types