code: def _get_valid_dicts(metadata_objects):
      """Get the valid dictionaries matching the metadata_objects."""
      info_dicts = []
      for metadata_object in metadata_objects:
          if isinstance(metadata_object, dict):
              metadata_dict = metadata_object
          elif hasattr(metadata_object, "attrs"):
              metadata_dict = metadata_object.attrs
          else:
              continue
          info_dicts.append(metadata_dict)
      return info_dicts
  
imports: from collections.abc import Collection
  from datetime import datetime
  from functools import partial, reduce
  from operator import eq, is_
  import numpy
  from satpy.writers.utils import flatten_dict
label_desc: Use image node_id 2 for calling a global function with example usage: _get_valid_dicts(metadata_objects) and returns: info_dicts