code: def _add_alpha(self, data, alpha=None):
          
          null_mask = alpha if alpha is not None else self._create_alpha(data)
          # if we are using integer data, then alpha needs to be min-int to max-int
          # otherwise for floats we want 0 to 1
          if np.issubdtype(data.dtype, np.integer):
              # xarray sometimes upcasts this calculation, so cast again
              null_mask = self._scale_to_dtype(null_mask, data.dtype).astype(data.dtype)
          data = xr.concat([data, null_mask], dim="bands")
          return data
docs: Create an alpha channel and concatenate it to the provided data.
  
          If ``data`` is an integer type then the alpha band will be scaled
          to use the smallest (min) value as fully transparent and the largest
          (max) value as fully opaque. For float types the alpha band spans
          0 to 1.