code: def as_op(itypes, otypes, infer_shape=None):
      """
      Decorator that converts a function into a basic PyTensor op that will call
      the supplied function as its implementation.
  
      It takes an optional infer_shape parameter that should be a callable with
      this signature:
  
          def infer_shape(fgraph, node, input_shapes):
              ...
              return output_shapes
  
      Here `input_shapes` and `output_shapes` are lists of tuples that represent
      the shape of the corresponding inputs/outputs.
  
      This should not be used when performance is a concern since the very basic
      nature of the resulting Op may interfere with certain graph optimizations.
  
      Examples
      --------
      @as_op(itypes=[pytensor.tensor.fmatrix, pytensor.tensor.fmatrix],
             otypes=[pytensor.tensor.fmatrix])
      def numpy_dot(a, b):
          return numpy.dot(a, b)
  
      """
      if not isinstance(itypes, (list, tuple)):
          itypes = [itypes]
      if not all(isinstance(t, CType) for t in itypes):
          raise TypeError("itypes has to be a list of PyTensor types")
      if not isinstance(otypes, (list, tuple)):
          otypes = [otypes]
      if not all(isinstance(t, CType) for t in otypes):
          raise TypeError("otypes has to be a list of PyTensor types")
  
      # make sure they are lists and not tuples
      itypes = list(itypes)
      otypes = list(otypes)
  
      if infer_shape is not None and not callable(infer_shape):
          raise TypeError("infer_shape needs to be a callable")
  
      def make_op(fn):
          return FromFunctionOp(fn, itypes, otypes, infer_shape)
  
      return make_op
  
imports: import copy
  import pickle
  import warnings
  from pytensor.graph.basic import Apply
  from pytensor.graph.op import Op
  from pytensor.link.c.op import COp
  from pytensor.link.c.type import CType
label_desc: Use image node_id 4 for calling a global function with example usage: as_op(itypes, otypes, infer_shape) and returns: make_op, FromFunctionOp