code: def add_time_bounds_dimension(
      ds: xr.Dataset, time: str = "time"
  ) -> xr.Dataset:
      """Add time bound dimension to xr.Dataset."""
      start_times = []
      end_times = []
      for _var_name, data_array in ds.items():
          start_times.append(data_array.attrs.get("start_time", None))
          end_times.append(data_array.attrs.get("end_time", None))
  
      start_time = min(
          start_time
          for start_time in start_times
          if start_time is not None
      )
      end_time = min(
          end_time for end_time in end_times if end_time is not None
      )
      ds["time_bnds"] = xr.DataArray(
          [
              [
                  np.datetime64(start_time, "ns"),
                  np.datetime64(end_time, "ns"),
              ]
          ],
          dims=["time", "bnds_1d"],
      )
      ds[time].attrs["bounds"] = "time_bnds"
      ds[time].attrs["standard_name"] = "time"
      return ds
  
imports: from __future__ import annotations
  import logging
  import warnings
  from collections import defaultdict
  from contextlib import suppress
  import numpy
  import xarray
  from dask.base import tokenize
  from pyproj import CRS
  from pyresample.geometry import AreaDefinition, SwathDefinition
label_desc: Use image node_id 21 for calling a global function with example usage: add_time_bounds_dimension(ds, time) and returns: ds