code: def ds_sync(args):
      dataset_created = False
      if args.parents or (args.project and args.name):
          args.id = ds_create(args)
          dataset_created = True
  
      print(
          "Syncing dataset id {} to local folder {}".format(
              args.id, args.folder
          )
      )
      check_null_id(args)
      print_args(args)
      ds = Dataset.get(dataset_id=args.id)
      removed, added, modified = ds.sync_folder(
          local_path=args.folder,
          dataset_path=args.dataset_folder or None,
          verbose=args.verbose,
      )
  
      print(
          "Sync completed: {} files removed, {} added, {} modified".format(
              removed, added, modified
          )
      )
  
      if not args.skip_close:
          if (
              dataset_created
              and not removed
              and not added
              and not modified
          ):
              print(
                  "Zero modifications on local copy, reverting dataset creation."
              )
              Dataset.delete(ds.id, force=True)
              return 0
  
          print("Finalizing dataset")
          if ds.is_dirty():
              # upload the files
              print(
                  "Pending uploads, starting dataset upload to {}".format(
                      args.storage or ds.get_default_storage()
                  )
              )
              ds.upload(
                  show_progress=True,
                  verbose=args.verbose,
                  output_url=args.storage or None,
                  chunk_size=args.chunk_size or -1,
              )
  
          ds.finalize()
          print("Dataset closed and finalized")
          clear_state()
  
      return 0
  
imports: import json
  import os
  import shutil
  from argparse import ArgumentParser, HelpFormatter
  from functools import partial
  from typing import Sequence
  from pathlib2 import Path
  import clearml.backend_api.session
  from clearml.datasets import Dataset
  from clearml.version import __version__
label_desc: Use image node_id 19 for calling a global function with example usage: ds_sync(args) and returns: int, int