def reorganize(raw_data_dir: str, out_dir: str):
    """Reorganize NYU Depth dataset files into the required directory
    structure.

    Args:
        raw_data_dir (str): Path to the raw data directory.
        out_dir (str): Output directory for the organized dataset.
    """

    def move_data(data_list, dst_prefix, fname_func):
        """Move data files from source to destination directory.

        Args:
            data_list (list): List of data file paths.
            dst_prefix (str): Prefix to be added to destination paths.
            fname_func (callable): Function to process file names
        """
        for data_item in data_list:
            data_item = data_item.strip().strip('/')
            new_item = fname_func(data_item)
            shutil.move(
                osp.join(raw_data_dir, data_item),
                osp.join(out_dir, dst_prefix, new_item))

    def process_phase(phase):
        """Process a dataset phase (e.g., 'train' or 'test')."""
        with open(osp.join(raw_data_dir, f'nyu_{phase}.txt')) as f:
            data = filter(lambda x: len(x.strip()) > 0, f.readlines())
            data = map(lambda x: x.split()[:2], data)
            images, annos = zip(*data)

            move_data(images, f'images/{phase}',
                      lambda x: x.replace('/rgb', ''))
            move_data(annos, f'annotations/{phase}',
                      lambda x: x.replace('/sync_depth', ''))

    process_phase('train')
    process_phase('test')
Reorganize NYU Depth dataset files into the required directory
    structure.

    Args:
        raw_data_dir (str): Path to the raw data directory.
        out_dir (str): Output directory for the organized dataset.
    
segmentation/tools/dataset_converters/nyu.py