code: def mask_raster(in_raster, mask, out_raster):
          
          if is_string(in_raster) and is_string(out_raster):
              in_raster = [str(in_raster)]
              out_raster = [str(out_raster)]
          if len(in_raster) != len(out_raster):
              raise RuntimeError('input raster and output raster must have the same size.')
  
          maskr = RasterUtilClass.read_raster(mask)
          rows = maskr.nRows
          cols = maskr.nCols
          maskdata = maskr.data
          temp = maskdata == maskr.noDataValue
          for inr, outr in zip(in_raster, out_raster):
              origin = RasterUtilClass.read_raster(inr)
              if origin.nRows == rows and origin.nCols == cols:
                  masked = numpy.where(temp, origin.noDataValue, origin.data)
              else:
                  masked = numpy.ones((rows, cols)) * origin.noDataValue
                  # TODO, the following loop should be optimized by numpy or numba
                  for i in range(rows):
                      for j in range(cols):
                          if maskdata[i][j] == maskr.noDataValue:
                              continue
                          # get the center point coordinate of current cell
                          tempx, tempy = maskr.get_central_coors(i, j)
                          tempv = origin.get_value_by_xy(tempx, tempy)
                          if tempv is None:
                              continue
                          masked[i][j] = tempv
              RasterUtilClass.write_gtiff_file(outr, maskr.nRows, maskr.nCols, masked,
                                               maskr.geotrans, maskr.srs,
                                               origin.noDataValue, origin.dataType)
docs: Mask raster data.
          Args:
              in_raster: list or one raster
              mask: Mask raster data
              out_raster: list or one raster