code: def binaryop_2d(c_op, py_op, commutative, x_gpu, y_gpu):
      if x_gpu.flags.c_contiguous != y_gpu.flags.c_contiguous:
          raise ValueError("unsupported combination of input order")
  
      if x_gpu.shape == y_gpu.shape:
          return py_op(x_gpu, y_gpu)
      elif x_gpu.size == 1:
          return py_op(x_gpu.get().reshape(()), y_gpu)
      elif y_gpu.size == 1:
          return py_op(x_gpu, y_gpu.get().reshape(()))
  
      if len(x_gpu.shape) == 2:
          m, n = x_gpu.shape
          if y_gpu.shape == (n,):
              return binaryop_matvec(c_op, x_gpu, y_gpu, axis=1)
          elif y_gpu.shape == (1, n):
              return binaryop_matvec(c_op, x_gpu, y_gpu[0], axis=1)
          elif y_gpu.shape == (m, 1):
              return binaryop_matvec(c_op, x_gpu, y_gpu.ravel(), axis=0)
  
      if len(y_gpu.shape) == 2 and commutative:
          m, n = y_gpu.shape
          if x_gpu.shape == (n,):
              return binaryop_matvec(c_op, y_gpu, x_gpu, axis=1)
          elif x_gpu.shape == (1, n):
              return binaryop_matvec(c_op, y_gpu, x_gpu[0], axis=1)
          elif x_gpu.shape == (m, 1):
              return binaryop_matvec(c_op, y_gpu, x_gpu.ravel(), axis=0)
  
      raise TypeError("unsupported combination of shapes")
  
imports: from __future__ import absolute_import, division
  import atexit
  import numbers
  from string import Template
  import pycuda.driver
  import pycuda.gpuarray
  import pycuda.elementwise
  import pycuda.reduction
  import pycuda.scan
  import pycuda.tools
  from pycuda.tools import context_dependent_memoize, dtype_to_ctype
  from pycuda.compiler import SourceModule
  from pytools import memoize
  import numpy
  from .None import cuda
  from .None import cublas
  import sys
  import operator
label_desc: Use image node_id 23 for calling a global function with example usage: binaryop_2d(c_op, py_op, commutative, x_gpu, y_gpu) and returns: py_op, py_op, binaryop_matvec, binaryop_matvec, py_op, binaryop_matvec, binaryop_matvec, binaryop_matvec, binaryop_matvec