code: def _stack_blend_by_weights(
      datasets: Sequence[xr.DataArray],
      weights: Sequence[xr.DataArray],
      combine_times: bool,
  ) -> xr.DataArray:
      """Stack datasets blending overlap using weights."""
      attrs = _combine_stacked_attrs(
          [data_arr.attrs for data_arr in datasets], combine_times
      )
  
      overlays = []
      for weight, overlay in zip(weights, datasets):
          # Any 'overlay' fill values should already be reflected in the weights
          # as 0. See _fill_weights_for_invalid_dataset_pixels. We fill NA with
          # 0 here to avoid NaNs affecting valid pixels in other datasets. Note
          # `.fillna` does not handle the `_FillValue` attribute so this filling
          # is purely to remove NaNs.
          overlays.append(overlay.fillna(0) * weight)
      # NOTE: Currently no way to ignore numpy divide by 0 warnings without
      # making a custom map_blocks version of the divide
      base = sum(overlays) / sum(weights)
  
      dims = datasets[0].dims
      blended_array = xr.DataArray(base, dims=dims, attrs=attrs)
      return blended_array
  
file_path: satpy/satpy/multiscene/_blend_funcs.py
imports: from __future__ import annotations
  from datetime import datetime
  from typing import Callable, Iterable, Mapping, Optional, Sequence
  import pandas
  import xarray
  from dask import array
  from satpy.dataset import combine_metadata
label_desc: Use image node_id 5 for calling a global function with example usage: _stack_blend_by_weights(datasets, weights, combine_times) and returns: blended_array