class_docstr: Abstract generator class.
      
docstr: Filter annotations by removing those that are outside of the image bounds or whose width/height < 0.
          
code: def filter_annotations(self, image_group, annotations_group, group):
      """Filter annotations by removing those that are outside of the image bounds or whose width/height < 0."""
      # test all annotations
      for index, (image, annotations) in enumerate(
          zip(image_group, annotations_group)
      ):
          # test x2 < x1 | y2 < y1 | x1 < 0 | y1 < 0 | x2 <= 0 | y2 <= 0 | x2 >= image.shape[1] | y2 >= image.shape[0]
          invalid_indices = np.where(
              (
                  annotations["bboxes"][:, 2]
                  <= annotations["bboxes"][:, 0]
              )
              | (
                  annotations["bboxes"][:, 3]
                  <= annotations["bboxes"][:, 1]
              )
              | (annotations["bboxes"][:, 0] < 0)
              | (annotations["bboxes"][:, 1] < 0)
              | (annotations["bboxes"][:, 2] > image.shape[1])
              | (annotations["bboxes"][:, 3] > image.shape[0])
          )[0]
  
          # delete invalid indices
          if len(invalid_indices):
              warnings.warn(
                  "Image {} with id {} (shape {}) contains the following invalid boxes: {}.".format(
                      self.image_path(group[index]),
                      group[index],
                      image.shape,
                      annotations["bboxes"][invalid_indices, :],
                  )
              )
              for k in annotations_group[index].keys():
                  annotations_group[index][k] = np.delete(
                      annotations[k], invalid_indices, axis=0
                  )
      return image_group, annotations_group
  
imports: import numpy
  import random
  import warnings
  from tensorflow import keras
  from ..utils.anchors import anchor_targets_bbox, anchors_for_shape, guess_shapes
  from ..utils.config import parse_anchor_parameters, parse_pyramid_levels
  from ..utils.image import TransformParameters, adjust_transform_for_image, apply_transform, preprocess_image, resize_image
  from ..utils.transform import transform_aabb
label_desc: Use image node_id 14 for calling the Generator obj's underlying member method code with example usage: obj.filter_annotations(image_group, annotations_group, group) and returns: image_group,  annotations_group