code: def np2gdal_dtype(d):
      
      dt_dict = gdal_array.codes        
      if isinstance(d, (np.ndarray, np.generic)):
          d = d.dtype
      #This creates dtype from another built-in type
      #d = np.dtype(d)
      if isinstance(d, np.dtype):
          if d.name == 'int8':
              gdal_dt = 1
          elif d.name == 'bool':
              #Write out as Byte
              gdal_dt = 1 
          else:
              gdal_dt = list(dt_dict.keys())[list(dt_dict.values()).index(d)]
      else:
          print("Input must be NumPy array or NumPy dtype")
          gdal_dt = None
      return gdal_dt
docs: Get GDAL RasterBand datatype that corresponds with NumPy datatype
      Input should be numpy array or numpy dtype