docs: def tile_decode(tile, tileindex, tileshape, tiledshape,
                  lsb2msb, decompress, unpack, unpredict, out):
      """Decode tile segment bytes into 5D output array."""
      _, imagedepth, imagelength, imagewidth, _ = out.shape
      tileddepth, tiledlength, tiledwidth = tiledshape
      tiledepth, tilelength, tilewidth, samples = tileshape
      tilesize = tiledepth * tilelength * tilewidth * samples
  
      pl = tileindex // (tiledwidth * tiledlength * tileddepth)
      td = (tileindex // (tiledwidth * tiledlength)) % tileddepth * tiledepth
      tl = (tileindex // tiledwidth) % tiledlength * tilelength
      tw = tileindex % tiledwidth * tilewidth
  
      if tile:
          if lsb2msb:
              tile = bitorder_decode(tile, out=tile)
          tile = decompress(tile)
          tile = unpack(tile)
          # decompression / unpacking might return too many bytes
          tile = tile[:tilesize]
          try:
              # complete tile according to TIFF specification
              tile.shape = tileshape
          except ValueError:
              # tile fills remaining space; found in some JPEG compressed slides
              s = (min(imagedepth - td, tiledepth),
                   min(imagelength - tl, tilelength),
                   min(imagewidth - tw, tilewidth),
                   samples)
              try:
                  tile.shape = s
              except ValueError:
                  # incomplete tile; see gdal issue #1179
                  log.warning('tile_decode: incomplete tile %s %s',
                              tile.shape, tileshape)
                  t = numpy.zeros(tilesize, tile.dtype)
                  s = min(tile.size, tilesize)
                  t[:s] = tile[:s]
                  tile = t.reshape(tileshape)
  
          tile = unpredict(tile, axis=-2, out=tile)
          out[pl, td:td+tiledepth, tl:tl+tilelength, tw:tw+tilewidth] = (
              tile[:imagedepth-td, :imagelength-tl, :imagewidth-tw])
      else:
          out[pl, td:td+tiledepth, tl:tl+tilelength, tw:tw+tilewidth] = 0