code: def local_gemm_to_gemv(fgraph, node):
      """GEMM acting on row or column matrices -> GEMV."""
      if node.op == gemm_no_inplace:
          z, a, x, y, b = node.inputs
          if z.broadcastable == x.broadcastable == (True, False):
              r = gemv_no_inplace(
                  z.dimshuffle(1), a, y.T, x.dimshuffle(1), b
              )
              new_out = [r.dimshuffle("x", 0)]
          elif z.broadcastable == y.broadcastable == (False, True):
              r = gemv_no_inplace(
                  z.dimshuffle(0), a, x, y.dimshuffle(0), b
              )
              new_out = [r.dimshuffle(0, "x")]
          else:
              return
          copy_stack_trace(node.outputs, new_out)
          return new_out
  
imports: import copy
  import logging
  import time
  import numpy
  from pytensor.tensor.rewriting.basic import register_specialize
  import pytensor.scalar
  from pytensor.compile.mode import optdb
  from pytensor.configdefaults import config
  from pytensor.graph.features import ReplacementDidNotRemoveError, ReplaceValidate
  from pytensor.graph.rewriting.basic import EquilibriumGraphRewriter, GraphRewriter, copy_stack_trace, in2out, node_rewriter
  from pytensor.graph.rewriting.db import SequenceDB
  from pytensor.graph.utils import InconsistencyError
  from pytensor.tensor import basic
  from pytensor.tensor.blas import Dot22, _dot22, _dot22scalar, batched_dot, gemm_inplace, gemm_no_inplace, gemv_inplace, gemv_no_inplace, ger, ger_destructive
  from pytensor.tensor.elemwise import DimShuffle, Elemwise
  from pytensor.tensor.exceptions import NotScalarConstantError
  from pytensor.tensor.math import Dot, _matrix_matrix_matmul, add, mul, neg, sub
  from pytensor.tensor.rewriting.elemwise import local_dimshuffle_lift
  from pytensor.tensor.type import DenseTensorType, TensorType, integer_dtypes, values_eq_approx_remove_inf_nan
label_desc: Use image node_id 14 for calling a global function with example usage: local_gemm_to_gemv(fgraph, node) and returns: new_out