class_docstr: Base video dataset for VID, MOT and VIS tasks.
class_docstr_tok: ["Base","video","dataset","for","VID",",","MOT","and","VIS","tasks","."]
docstr: Filter image annotations according to filter_cfg.
  
  Returns:
      list[int]: Filtered results.
docstr_tok: ["Filter","image","annotations","according","to","filter_cfg",".","Returns",":","list","[","int","]",":","Filtered","results","."]
code: def filter_data(self) -> List[int]:
      """Filter image annotations according to filter_cfg.
  
      Returns:
          list[int]: Filtered results.
      """
      if self.test_mode:
          return self.data_list
  
      num_imgs_before_filter = sum(
          [len(info["images"]) for info in self.data_list]
      )
      num_imgs_after_filter = 0
  
      # obtain images that contain annotations of the required categories
      ids_in_cat = set()
      for i, class_id in enumerate(self.cat_ids):
          ids_in_cat |= set(self.cat_img_map[class_id])
      # merge the image id sets of the two conditions and use the merged set
      # to filter out images if self.filter_empty_gt=True
      ids_in_cat &= self.img_ids_with_ann
  
      new_data_list = []
      for video_data_info in self.data_list:
          imgs_data_info = video_data_info["images"]
          valid_imgs_data_info = []
  
          for data_info in imgs_data_info:
              img_id = data_info["img_id"]
              width = data_info["width"]
              height = data_info["height"]
              # TODO: simplify these conditions
              if self.filter_cfg is None:
                  if img_id not in ids_in_cat:
                      video_data_info["video_length"] -= 1
                      continue
                  if min(width, height) >= 32:
                      valid_imgs_data_info.append(data_info)
                      num_imgs_after_filter += 1
                  else:
                      video_data_info["video_length"] -= 1
              else:
                  if (
                      self.filter_cfg.get("filter_empty_gt", True)
                      and img_id not in ids_in_cat
                  ):
                      video_data_info["video_length"] -= 1
                      continue
                  if min(width, height) >= self.filter_cfg.get(
                      "min_size", 32
                  ):
                      valid_imgs_data_info.append(data_info)
                      num_imgs_after_filter += 1
                  else:
                      video_data_info["video_length"] -= 1
              video_data_info["images"] = valid_imgs_data_info
          new_data_list.append(video_data_info)
  
      print_log(
          "The number of samples before and after filtering: "
          f"{num_imgs_before_filter} / {num_imgs_after_filter}",
          "current",
      )
      return new_data_list
  
file_path: mmdetection/mmdet/datasets/base_video_dataset.py
imports: import copy
  import os.path
  from collections import defaultdict
  from typing import Any, List, Tuple
  import mmengine.fileio
  from mmengine.dataset import BaseDataset
  from mmengine.logging import print_log
  from mmdet.datasets.api_wrappers import COCO
  from mmdet.registry import DATASETS
label_desc: Use image node_id 4 for calling the BaseVideoDataset obj's underlying member method code with example usage: obj.filter_data() and returns: new_data_list, self