code: def _extended_convolution(
      input_tensor,
      kernel,
      strides,
      dilations,
      padding,
      constant=0,
      name="extended_convolution",
  ):
      """
      A simple wrapper for tf.nn.convolution that first expands the input tensor
      by sampling at discrete locations in the original tensor then invokes
      the original convolution operation on the expanded tensor, and finally
      extracts a suitable output tensor from the output of the convolution of
      the expanded tensor.
      :param input_tensor: original convolution input tensor
      :param kernel: convolution kernel
      :param strides: strided convolution strides (one per spatial dimension)
      :param dilations: dilated convolution dilation factors
      (one per spatial dimension)
      :param padding: a string specifying the type of padding to apply
      :param constant: a padding constant (only read in the case of constant
      padding)
      :param name: a name for the operation
      :return: a convolution result of the same size as the input tensor
      """
  
      input_shape = input_tensor.shape.as_list()
      batch_size = input_shape[0]
      input_shape = input_shape[1:-1]
      kernel_shape = kernel.shape.as_list()
      nof_output_features = kernel_shape[-1]
      kernel_shape = kernel_shape[:-2]
  
      if any(
          i is None or i < 0 or k is None or k < 0
          for i, k in zip(input_shape, kernel_shape)
      ):
          raise ValueError(
              "The dimensions of the input tensor and the filter"
              " must be known in advance for this operation to "
              "work."
          )
  
      output_shape = [
          int(math.ceil(i / s)) for i, s in zip(input_shape, strides)
      ]
      output_shape = [batch_size] + output_shape + [nof_output_features]
  
      dimpads = [0]
      for i, k, s, d in zip(
          input_shape, kernel_shape, strides, dilations
      ):
          pad = _compute_pad_size(i, int(math.ceil(i / s)), k, s, d)
          dimpads.append(pad)
      dimpads += [0]
  
      # Cannot pad by more than 1 dimension size => repeatedly pad
      if padding in ("REFLECT", "SYMMETRIC"):
          padded_input = input_tensor
          offset = int(padding == "REFLECT")
  
          while (
              min(
                  o - i - 2 * p
                  for o, i, p in zip(
                      padded_input.shape.as_list()[1:-1],
                      input_shape,
                      dimpads[1:-1],
                  )
              )
              < 0
          ):
              effective_pad = [(0, 0)]
              padded_shape = padded_input.shape.as_list()[1:-1]
              for i in range(len(input_shape)):
                  epad = min(
                      (
                          input_shape[i]
                          + 2 * dimpads[1 + i]
                          - padded_shape[i]
                      )
                      // 2,
                      padded_shape[i] - offset,
                  )
                  epad = max(epad, 0)
                  effective_pad.append((epad, epad))
              effective_pad += [(0, 0)]
  
              assert max(e for e, _ in effective_pad) > 0
  
              padded_input = tf.pad(
                  padded_input, effective_pad, mode=padding
              )
      else:
          padded_input = tf.pad(
              input_tensor,
              [(d, d) for d in dimpads],
              mode=padding,
              constant_values=constant,
          )
  
      conv_output = tf.nn.convolution(
          input=padded_input,
          filter=kernel,
          strides=strides,
          dilation_rate=dilations,
          padding="SAME",
          name="conv_" + name,
      )
  
      conv_output_shape = conv_output.shape.as_list()
      out_pad = [0]
      out_pad += [
          (o - i) // 2
          for i, o in zip(output_shape[1:-1], conv_output_shape[1:-1])
      ]
      out_pad += [0]
  
      return (
          tf.slice(conv_output, out_pad, output_shape)
          if max(out_pad) > 0
          else conv_output
      )
  
imports: from __future__ import absolute_import, print_function
  import math
  import numpy
  import tensorflow
  from niftynet.layer import layer_util
  from niftynet.layer.activation import ActiLayer
  from niftynet.layer.base_layer import TrainableLayer
  from niftynet.layer.bn import BNLayer, InstanceNormLayer
  from niftynet.layer.gn import GNLayer
  from niftynet.utilities.util_common import look_up_operations
label_desc: Use image node_id 4 for calling a global function with example usage: _extended_convolution(input_tensor, kernel, strides, dilations, padding, constant, name) and returns: unknown