code: def select_to_keep(samples, existing_dataset=None):
      if existing_dataset is None:
          existing_dataset = set()
  
      def get_dim(s):
          return s.width * s.height
  
      def get_duration(s):
          return len(s) / s.fps * 1000
  
      def cond_dim(sample, keep):
          return get_dim(sample) > get_dim(keep)
  
      def cond_duration(sample, keep):
          return get_dim(sample) >= (get_dim(keep) * 0.95) and (
              get_duration(sample) - get_duration(keep) > 5000
          )
  
      keep = samples[0]
      for sample in samples[1:]:
          if sample.id in existing_dataset:
              keep = sample
          elif cond_dim(sample, keep) and not cond_duration(
              keep, sample
          ):
              keep = sample
          elif cond_duration(sample, keep):
              keep = sample
  
      remove_dups = [
          s
          for s in samples
          if (s != keep) and (s.id not in existing_dataset)
      ]
      return keep, remove_dups
  
file_path: gluon-cv/gluoncv/torch/data/gluoncv_motion_dataset/ingestion/duplicate_remover.py
imports: import logging
  from pathlib import Path, PosixPath
  from collections import defaultdict
  import tqdm
  from ..dataset import GluonCVMotionDataset, get_vis_thumb_location
  from ..utils.ingestion_utils import get_chunked_id_map
label_desc: Use image node_id 4 for calling a global function with example usage: select_to_keep(samples, existing_dataset) and returns: keep,  remove_dups, unknown, unknown, unknown, unknown