code: def make_checks(loop_orders, dtypes, sub):
      init = ""
      for i, (loop_order, dtype) in enumerate(zip(loop_orders, dtypes)):
          var = "%%(lv%i)s" % i
          # List of dimensions of var that are not broadcasted
          nonx = [x for x in loop_order if x != "x"]
          if nonx:
              # If there are dimensions that are not broadcasted
              # this is a check that the number of dimensions of the
              # tensor is as expected.
              min_nd = max(nonx) + 1
              init += (
                  """
              if (PyArray_NDIM(%(var)s) < %(min_nd)s) {
                  PyErr_SetString(PyExc_ValueError, "Not enough dimensions on input.");
                  %%(fail)s
              }
              """
                  % locals()
              )
  
          # In loop j, adjust represents the difference of values of the
          # data pointer between the beginning and the end of the
          # execution of loop j+1 (the loop inside the current one). It
          # is equal to the stride in loop j+1 times the length of loop
          # j+1, or 0 for the inner-most loop.
          adjust = "0"
  
          # We go from the inner loop to the outer loop
          for j, index in reversed(list(enumerate(loop_order))):
              if index != "x":
                  # Initialize the variables associated to the jth loop
                  # jump = stride - adjust
                  jump = "(%s) - (%s)" % (
                      "%(var)s_stride%(index)s" % locals(),
                      adjust,
                  )
                  init += (
                      """
                  %(var)s_n%(index)s = PyArray_DIMS(%(var)s)[%(index)s];
                  %(var)s_stride%(index)s = PyArray_STRIDES(%(var)s)[%(index)s] / sizeof(%(dtype)s);
                  %(var)s_jump%(index)s_%(j)s = %(jump)s;
                  """
                      % locals()
                  )
                  adjust = (
                      "%(var)s_n%(index)s*%(var)s_stride%(index)s"
                      % locals()
                  )
              else:
                  jump = "-(%s)" % adjust
                  init += (
                      """
                  %(var)s_jump%(index)s_%(j)s = %(jump)s;
                  """
                      % locals()
                  )
                  adjust = "0"
      check = ""
  
      # This loop builds multiple if conditions to verify that the
      # dimensions of the inputs match, and the first one that is true
      # raises an informative error message
      for matches in zip(*loop_orders):
          to_compare = [
              (j, x) for j, x in enumerate(matches) if x != "x"
          ]
  
          # elements of to_compare are pairs ( input_variable_idx, input_variable_dim_idx )
          if len(to_compare) < 2:
              continue
          j0, x0 = to_compare[0]
          for j, x in to_compare[1:]:
              check += (
                  """
              if (%%(lv%(j0)s)s_n%(x0)s != %%(lv%(j)s)s_n%(x)s)
              {
                  PyErr_Format(PyExc_ValueError, "Input dimension mis-match. (input[%%%%i].shape[%%%%i] = %%%%lld, input[%%%%i].shape[%%%%i] = %%%%lld)",
                     %(j0)s,
                     %(x0)s,
                     (long long int) %%(lv%(j0)s)s_n%(x0)s,
                     %(j)s,
                     %(x)s,
                     (long long int) %%(lv%(j)s)s_n%(x)s
                  );
                  %%(fail)s
              }
              """
                  % locals()
              )
  
      return init % sub + check % sub
  
file_path: Theano/theano/tensor/elemwise_cgen.py
imports: from __future__ import absolute_import, print_function, division
  from six.moves import xrange
  import theano
label_desc: Use image node_id 2 for calling a global function with example usage: make_checks(loop_orders, dtypes, sub) and returns: unknown