code: def filter_images_with_only_crowd_annotations(dataset_dicts):
      """
      Filter out images with none annotations or only crowd annotations
      (i.e., images without non-crowd annotations).
      A common training-time preprocessing on COCO dataset.
  
      Args:
          dataset_dicts (list[dict]): annotations in Detectron2 Dataset format.
  
      Returns:
          list[dict]: the same format, but filtered.
      """
      num_before = len(dataset_dicts)
  
      def valid(anns):
          for ann in anns:
              if ann.get("iscrowd", 0) == 0:
                  return True
          return False
  
      dataset_dicts = [
          x for x in dataset_dicts if valid(x["annotations"])
      ]
      num_after = len(dataset_dicts)
      logger = logging.getLogger(__name__)
      logger.info(
          "Removed {} images with no usable annotations. {} images left.".format(
              num_before - num_after, num_after
          )
      )
      return dataset_dicts
  
imports: import itertools
  import random
  import logging
  import operator
  import dill
  import pickle
  from pprint import pformat
  from typing import List, Optional, Union
  import numpy
  import torch
  import torch.utils.data
  from ..structures import BoxMode
  from ...utils.comm import get_world_size
  from ...utils.random import seed_all_rng
  from ..transforms import instance_transforms
  from ..registry.catalog import DatasetCatalog, MetadataCatalog
  from .detection_utils import check_metadata_consistency
  from .None import detection_utils
  from .samplers import InferenceSampler, RepeatFactorTrainingSampler, TrainingSampler
label_desc: Use image node_id 1 for calling a global function with example usage: filter_images_with_only_crowd_annotations(dataset_dicts) and returns: dataset_dicts, False, True