code: def _get_linear_filter(size, ndim, upsampling=True):
      """Make a 2D and 3D linear kernel suitable for up/downsampling"""
      factor = (size + 1) // 2
      if size % 2 == 1:
          center = factor - 1.0
      else:
          center = factor - 0.5
      slices = (slice(size),) * ndim
      og = numpy.ogrid[slices]
      filt = 1.0
      for og_i in og:
          filt = filt * (1.0 - abs(og_i - center) / factor)
      if not upsampling:
          filt /= filt.sum()
      return filt
  
file_path: chainer/chainer/initializers/sampling.py
imports: import numpy
  from chainer.backends import cuda
  from chainer import initializer
label_desc: Use image node_id 1 for calling a global function with example usage: _get_linear_filter(size, ndim, upsampling) and returns: filt