code: def _ir_calibrate(header, data, irchn, calib_type, mask=True):
      """Calibrate for IR bands.
  
      *calib_type* in brightness_temperature, radiance, count
  
      """
      channel_data = data["hrpt"][:, :, irchn + 2]
      chunks = get_aapp_chunks(channel_data.shape)
      line_chunks = chunks[0]
  
      count = da.from_array(channel_data, chunks=chunks)
  
      if calib_type == 0:
          return count
  
      # Mask unnaturally low values
      mask &= count != 0
      count = count.astype(CHANNEL_DTYPE)
  
      k1_ = (
          da.from_array(
              data["calir"][:, irchn, 0, 0], chunks=line_chunks
          )
          / 1.0e9
      )
      k2_ = (
          da.from_array(
              data["calir"][:, irchn, 0, 1], chunks=line_chunks
          )
          / 1.0e6
      )
      k3_ = (
          da.from_array(
              data["calir"][:, irchn, 0, 2], chunks=line_chunks
          )
          / 1.0e6
      )
  
      # Count to radiance conversion:
      rad = (
          k1_[:, None] * count * count
          + k2_[:, None] * count
          + k3_[:, None]
      )
  
      # Suspicious lines
      mask &= ((k1_ != 0) | (k2_ != 0) | (k3_ != 0))[:, None]
  
      if calib_type == 2:
          mask &= rad > 0.0
          return da.where(mask, rad, np.nan)
  
      # Central wavenumber:
      cwnum = header["radtempcnv"][0, irchn, 0]
      if irchn == 0:
          cwnum = cwnum / 1.0e2
      else:
          cwnum = cwnum / 1.0e3
  
      bandcor_2 = header["radtempcnv"][0, irchn, 1] / 1e5
      bandcor_3 = header["radtempcnv"][0, irchn, 2] / 1e6
  
      ir_const_1 = 1.1910659e-5
      ir_const_2 = 1.438833
  
      t_planck = (ir_const_2 * cwnum) / np.log(
          1 + ir_const_1 * cwnum * cwnum * cwnum / rad
      )
  
      # Band corrections applied to t_planck to get correct
      # brightness temperature for channel:
      if bandcor_2 < 0:  # Post AAPP-v4
          tb_ = bandcor_2 + bandcor_3 * t_planck
      else:  # AAPP 1 to 4
          tb_ = (t_planck - bandcor_2) / bandcor_3
  
      # Mask unnaturally low values
  
      return da.where(mask, tb_, np.nan)
  
imports: import functools
  import logging
  from datetime import datetime, timedelta
  import dask.array
  import numpy
  import xarray
  from dask import delayed
  from satpy.readers.file_handlers import BaseFileHandler
  from satpy.utils import get_chunk_size_limit
label_desc: Use image node_id 5 for calling a global function with example usage: _ir_calibrate(header, data, irchn, calib_type, mask) and returns: da, count, da