docs: def load_image(file) -> DataAndMetadata.DataAndMetadata:
      """
      Loads the image from the file-like object or string file.
      If file is a string, the file is opened and then read.
      Returns a numpy ndarray of our best guess for the most important image
      in the file.
      """
      if isinstance(file, str) or isinstance(file, str):
          with open(file, "rb") as f:
              return load_image(f)
      dmtag = parse_dm3.parse_dm_header(file)
      dmtag = fix_strings(dmtag)
      # display_keys(dmtag)
      img_index = -1
      image_tags = dmtag['ImageList'][img_index]
      data = imagedatadict_to_ndarray(image_tags['ImageData'])
      calibrations = []
      calibration_tags = image_tags['ImageData'].get('Calibrations', dict())
      for dimension in calibration_tags.get('Dimension', list()):
          origin, scale, units = dimension.get('Origin', 0.0), dimension.get('Scale', 1.0), dimension.get('Units', str())
          calibrations.append((-origin * scale, scale, units))
      calibrations = tuple(reversed(calibrations))
      if len(data.shape) == 3 and data.dtype != numpy.uint8:
          if image_tags['ImageTags'].get('Meta Data', dict()).get("Format", str()).lower() in ("spectrum", "spectrum image"):
              if data.shape[1] == 1:
                  data = numpy.squeeze(data, 1)
                  data = numpy.moveaxis(data, 0, 1)
                  data_descriptor = DataAndMetadata.DataDescriptor(False, 1, 1)
                  calibrations = (calibrations[2], calibrations[0])
              else:
                  data = numpy.moveaxis(data, 0, 2)
                  data_descriptor = DataAndMetadata.DataDescriptor(False, 2, 1)
                  calibrations = tuple(calibrations[1:]) + (calibrations[0],)
          else:
              data_descriptor = DataAndMetadata.DataDescriptor(False, 1, 2)
      elif len(data.shape) == 4 and data.dtype != numpy.uint8:
          # data = numpy.moveaxis(data, 0, 2)
          data_descriptor = DataAndMetadata.DataDescriptor(False, 2, 2)
      elif data.dtype == numpy.uint8:
          data_descriptor = DataAndMetadata.DataDescriptor(False, 0, len(data.shape[:-1]))
      else:
          data_descriptor = DataAndMetadata.DataDescriptor(False, 0, len(data.shape))
      brightness = calibration_tags.get('Brightness', dict())
      origin, scale, units = brightness.get('Origin', 0.0), brightness.get('Scale', 1.0), brightness.get('Units', str())
      intensity = -origin * scale, scale, units
      timestamp = None
      timezone = None
      timezone_offset = None
      title = image_tags.get('Name')
      properties = dict()
      if 'ImageTags' in image_tags:
          voltage = image_tags['ImageTags'].get('ImageScanned', dict()).get('EHT', dict())
          if voltage:
              properties.setdefault("hardware_source", dict())["autostem"] = { "high_tension_v": float(voltage) }
          dm_metadata_signal = image_tags['ImageTags'].get('Meta Data', dict()).get('Signal')
          if dm_metadata_signal and dm_metadata_signal.lower() == "eels":
              properties.setdefault("hardware_source", dict())["signal_type"] = dm_metadata_signal
          if image_tags['ImageTags'].get('Meta Data', dict()).get("Format", str()).lower() in ("spectrum", "spectrum image"):
              data_descriptor.collection_dimension_count += data_descriptor.datum_dimension_count - 1
              data_descriptor.datum_dimension_count = 1
          if image_tags['ImageTags'].get('Meta Data', dict()).get("IsSequence", False) and data_descriptor.collection_dimension_count > 0:
              data_descriptor.is_sequence = True
              data_descriptor.collection_dimension_count -= 1
          timestamp_str = image_tags['ImageTags'].get("Timestamp")
          if timestamp_str:
              timestamp = get_datetime_from_timestamp_str(timestamp_str)
          timezone = image_tags['ImageTags'].get("Timezone")
          timezone_offset = image_tags['ImageTags'].get("TimezoneOffset")
          # to avoid having duplicate copies in Swift, get rid of these tags
          image_tags['ImageTags'].pop("Timestamp", None)
          image_tags['ImageTags'].pop("Timezone", None)
          image_tags['ImageTags'].pop("TimezoneOffset", None)
          # put the image tags into properties
          properties.update(image_tags['ImageTags'])
      dimensional_calibrations = [Calibration.Calibration(c[0], c[1], c[2]) for c in calibrations]
      while len(dimensional_calibrations) < data_descriptor.expected_dimension_count:
          dimensional_calibrations.append(Calibration.Calibration())
      intensity_calibration = Calibration.Calibration(intensity[0], intensity[1], intensity[2])
      return DataAndMetadata.new_data_and_metadata(data,
                                                   data_descriptor=data_descriptor,
                                                   dimensional_calibrations=dimensional_calibrations,
                                                   intensity_calibration=intensity_calibration,
                                                   metadata=properties,
                                                   timestamp=timestamp,
                                                   timezone=timezone,
                                                   timezone_offset=timezone_offset)