code: def _stack_bands(sources, write_raster=False, dest=None):
      """Stack a set of bands into a single file.
  
      Parameters
      ----------
      sources : list of rasterio dataset objects
          A list of rasterio dataset objects you wish to stack. Objects
          will be stacked in the order provided in this list.
      dest : string (optional)
          Path to the where the output raster containing the stacked
          layers will be stored.
      write_raster : bool (default=False)
          Boolean to determine whether or not to write out the raster.
  
      Returns
      ----------
      tuple
  
          numpy array
              Numpy array generated from the stacked array combining all
              bands that were provided in the list.
          ret_prof : rasterio profile
              Updated rasterio spatial metadata object updated to represent
              the number of layers in the stack
      """
  
      try:
          for src in sources:
              src.profile
  
      except AttributeError:
          raise AttributeError(
              "The sources object should be Dataset Reader"
          )
          sys.exit()
  
      else:
          pass
  
      if write_raster:
          for ii, ifile in enumerate(sources):
              bands = sources[ii].read()
              if bands.ndim != 3:
                  bands = bands[np.newaxis, ...]
              for band in bands:
                  dest.write(band, ii + 1)
  
      else:
          stacked_arr = []
          for ii, ifile in enumerate(sources):
              bands = sources[ii].read()
              if bands.shape[0] == 1:
                  bands = np.squeeze(bands)
              stacked_arr.append(bands)
  
          # Update the profile to have count==number of bands
          ret_prof = sources[0].profile.copy()
          ret_prof["count"] = len(stacked_arr)
  
          return np.array(stacked_arr), ret_prof
  
file_path: earthpy/earthpy/spatial.py
imports: import os
  import sys
  import contextlib
  import warnings
  import numpy
  from shapely.geometry import mapping, box
  import geopandas
  import rasterio
  from rasterio.mask import mask
label_desc: Use image node_id 4 for calling a global function with example usage: _stack_bands(sources, write_raster, dest) and returns: np,  ret_prof