code: def solve_triangular_impl(
      A, B, trans=0, lower=False, unit_diagonal=False
  ):
      ensure_lapack()
  
      _check_scipy_linalg_matrix(A, "solve_triangular")
      _check_scipy_linalg_matrix(B, "solve_triangular")
      dtype = A.dtype
      w_type = _get_underlying_float(dtype)
      numba_trtrs = _LAPACK().numba_xtrtrs(dtype)
  
      def impl(A, B, trans=0, lower=False, unit_diagonal=False):
          B_is_1d = B.ndim == 1
  
          _N = np.int32(A.shape[-1])
          if A.shape[-2] != _N:
              raise linalg.LinAlgError(
                  "Last 2 dimensions of A must be square"
              )
  
          if A.shape[0] != B.shape[0]:
              raise linalg.LinAlgError(
                  "Dimensions of A and B do not conform"
              )
  
          if B_is_1d:
              B_copy = np.asfortranarray(np.expand_dims(B, -1))
          else:
              B_copy = _copy_to_fortran_order(B)
  
          if trans not in [0, 1, 2]:
              raise ValueError(
                  'Parameter "trans" should be one of N, C, T or 0, 1, 2'
              )
          if trans == 0:
              transval = ord("N")
          elif trans == 1:
              transval = ord("T")
          else:
              transval = ord("C")
  
          B_NDIM = 1 if B_is_1d else int(B.shape[1])
  
          UPLO = val_to_int_ptr(ord("L") if lower else ord("U"))
          TRANS = val_to_int_ptr(transval)
          DIAG = val_to_int_ptr(ord("U") if unit_diagonal else ord("N"))
          N = val_to_int_ptr(_N)
          NRHS = val_to_int_ptr(B_NDIM)
          LDA = val_to_int_ptr(_N)
          LDB = val_to_int_ptr(_N)
          INFO = val_to_int_ptr(0)
  
          numba_trtrs(
              UPLO,
              TRANS,
              DIAG,
              N,
              NRHS,
              np.asfortranarray(A).T.view(w_type).ctypes,
              LDA,
              B_copy.view(w_type).ctypes,
              LDB,
              INFO,
          )
  
          if B_is_1d:
              return B_copy[..., 0], int_ptr_to_val(INFO)
          return B_copy, int_ptr_to_val(INFO)
  
      return impl
  
imports: import ctypes
  import numba
  import numpy
  from numba.core import cgutils, types
  from numba.extending import get_cython_function_address, intrinsic, overload
  from numba.np.linalg import _copy_to_fortran_order, ensure_lapack, get_blas_kind
  from scipy import linalg
  from pytensor.link.numba.dispatch import basic
  from pytensor.link.numba.dispatch.basic import numba_funcify
  from pytensor.tensor.slinalg import BlockDiagonal, Cholesky, SolveTriangular
label_desc: Use image node_id 14 for calling a global function with example usage: solve_triangular_impl(A, B, trans, lower, unit_diagonal) and returns: impl, B_copy,  int_ptr_to_val, B_copy,  int_ptr_to_val