code: def get_frames_with_masks(data_path, ext="png", mask_ext="_mask.png"):
      frame_groups = {}
  
      # Go over each jpg file in base path
      for file in glob.glob(
          os.path.join(data_path, "*.{}".format(ext))
      ):
          full_path = os.path.abspath(file)
  
          # if this is a mask file skip it, we will manually add it later to the images it belongs to
          if full_path.endswith(mask_ext):
              continue
  
          # let's check if we have a mask file
          full_path_mask = full_path.replace(f".{ext}", mask_ext)
          if not os.path.exists(full_path_mask):
              # we do not have a mask file, so let's skip this one
              continue
  
          # now we need to add the actual
          print("Getting files from: " + full_path)
  
          # let's split the file name based on '_' and use the first part as ID
          file_parts_key = os.path.split(full_path)[-1].split("_")
  
          # this is used just so we can easily collect (group) the frames together
          frame_group_id = file_parts_key[0]
          # find the correct FrameGroup based on the filename
          if frame_group_id not in frame_groups:
              # this is acts like a Dict and the keys are string and the values are SingleFrames
              frame_group = FrameGroup()
              frame_groups[frame_group_id] = frame_group
          else:
              frame_group = frame_groups[frame_group_id]
  
          # add the frame and the mask to the frame group,
          # we have to give it a name (inside the FrameGroup) so we use
          source_id = file_parts_key[1]
          frame_group[source_id] = SingleFrame(
              source=full_path, mask_source=full_path_mask
          )
  
      # return a list of FrameGroups
      return list(frame_groups.values())
  
file_path: clearml/examples/hyperdatasets/data-registration/register_dataset_masks.py
imports: import glob
  import json
  import os
  from argparse import ArgumentParser
  from allegroai import DatasetVersion, FrameGroup, SingleFrame, Task
  from clearml import StorageManager
label_desc: Use image node_id 1 for calling a global function with example usage: get_frames_with_masks(data_path, ext, mask_ext) and returns: list