code: def pyconv3d(signals, filters, border_mode="valid"):
      Ns, Ts, C, Hs, Ws = signals.shape
      Nf, Tf, C, Hf, Wf = filters.shape
  
      # if border_mode is not 'valid', the signals need zero-padding
      if border_mode == "full":
          Tpad = Tf - 1
          Hpad = Hf - 1
          Wpad = Wf - 1
      elif border_mode == "half":
          Tpad = Tf // 2
          Hpad = Hf // 2
          Wpad = Wf // 2
      else:
          Tpad = 0
          Hpad = 0
          Wpad = 0
  
      if Tpad > 0 or Hpad > 0 or Wpad > 0:
          # zero-pad signals
          signals_padded = np.zeros(
              (Ns, Ts + 2 * Tpad, C, Hs + 2 * Hpad, Ws + 2 * Wpad),
              "float32",
          )
          signals_padded[
              :,
              Tpad : (Ts + Tpad),
              :,
              Hpad : (Hs + Hpad),
              Wpad : (Ws + Wpad),
          ] = signals
          Ns, Ts, C, Hs, Ws = signals_padded.shape
          signals = signals_padded
  
      Tf2 = Tf // 2
      Hf2 = Hf // 2
      Wf2 = Wf // 2
  
      rval = np.zeros((Ns, Ts - Tf + 1, Nf, Hs - Hf + 1, Ws - Wf + 1))
      for ns in xrange(Ns):
          for nf in xrange(Nf):
              for c in xrange(C):
                  s_i = signals[ns, :, c, :, :]
                  f_i = filters[nf, :, c, :, :]
                  r_i = rval[ns, :, nf, :, :]
                  o_i = ndimage.convolve(
                      s_i, f_i, mode="constant", cval=1
                  )
                  o_i_sh0 = o_i.shape[0]
                  # print s_i.shape, f_i.shape, r_i.shape, o_i.shape
                  r_i += o_i[Tf2 : o_i_sh0 - Tf2, Hf2:-Hf2, Wf2:-Wf2]
      return rval
  
file_path: Theano/theano/tensor/nnet/tests/test_conv3d2d.py
imports: from __future__ import absolute_import, print_function, division
  import time
  from nose.plugins.skip import SkipTest
  from parameterized import parameterized
  import numpy
  from six.moves import xrange
  import theano
  from theano.gof.opt import check_stack_trace
  from theano.tensor.nnet.conv3d2d import conv3d, get_diagonal_subtensor_view, DiagonalSubtensor, IncDiagonalSubtensor
  import theano.tests.unittest_tools
label_desc: Use image node_id 2 for calling a global function with example usage: pyconv3d(signals, filters, border_mode) and returns: rval