code: def linear_symbolic(A=None, b=None, G=None, h=None, variables=None):
      """convert linear equality and inequality constraints from matrices to a
      symbolic string of the form required by mystic's constraint parser.
  
      Args:
          A (ndarray, default=None): matrix of coefficients of equality constraints
          b (ndarray, default=None): vector of solutions of equality constraints
          G (ndarray, default=None): matrix of coefficients of inequality constraints
          h (ndarray, default=None): vector of solutions of inequality constraints
          variables (list[str], default=None): list of variable names
  
      Notes:
          if ``variables=None``, then ``variables = ['x0', 'x1', ...]``;
          if ``variables='y'``, then ``variables = ['y0', 'y1', ...]``;
          otherwise use the explicit list of variables provided.
  
          Must provide ``A, b``, ``G, h``, or ``A, b, G, h``;
          where ``Ax = b`` and ``Gx <= h``.
  
      Examples:
          >>> A = [[3., 4., 5.],
          ...      [1., 6., -9.]]
          >>> b = [0., 0.]
          >>> G = [1., 0., 0.]
          >>> h = [5.]
          >>> print(linear_symbolic(A,b,G,h))
          1.0*x0 + 0.0*x1 + 0.0*x2 <= 5.0
          3.0*x0 + 4.0*x1 + 5.0*x2 = 0.0
          1.0*x0 + 6.0*x1 + -9.0*x2 = 0.0"""
      if variables is None:
          variables = "x"
      has_base = isinstance(variables, str)
  
      eqstring = ""
      # Equality constraints
      if A is not None and b is not None:
          # If one-dimensional and not in a nested list, add a list layer
          try:
              ndim = len(A[0])
          except:
              ndim = len(A)
              A = [A]
  
          # Flatten b, in case it's in the form [[0, 1, 2]] for example.
          if len(b) == 1:
              b = ndarray.flatten(asarray(b)).tolist()
  
          # Check dimensions and give errors if incorrect.
          if len(A) != len(b):  # NOTE: changed from Exception 11/15/21
              raise ValueError(
                  "dimensions of A and b are not consistent"
              )
  
          if has_base:
              names = [variables + str(j) for j in range(ndim)]
          else:
              if len(variables) != ndim:
                  raise ValueError("variables is not consistent with A")
              names = variables
  
          # 'matrix multiply' and form the string
          for i in range(len(b)):
              Asum = ""
              for j in range(ndim):
                  Asum += str(A[i][j]) + "*" + names[j] + " + "
              eqstring += Asum.rstrip(" + ") + " = " + str(b[i]) + "\n"
  
      # Inequality constraints
      ineqstring = ""
      if G is not None and h is not None:
          # If one-dimensional and not in a nested list, add a list layer
          try:
              ndim = len(G[0])
          except:
              ndim = len(G)
              G = [G]
  
          # Flatten h, in case it's in the form [[0, 1, 2]] for example.
          if len(h) == 1:
              h = ndarray.flatten(asarray(h)).tolist()
  
          # Check dimensions and give errors if incorrect.
          if len(G) != len(h):  # NOTE: changed from Exception 11/15/21
              raise ValueError(
                  "dimensions of G and h are not consistent"
              )
  
          if has_base:
              names = [variables + str(j) for j in range(ndim)]
          else:
              if len(variables) != ndim:
                  raise ValueError("variables is not consistent with G")
              names = variables
  
          # 'matrix multiply' and form the string
          for i in range(len(h)):
              Gsum = ""
              for j in range(ndim):
                  Gsum += str(G[i][j]) + "*" + names[j] + " + "
              ineqstring += (
                  Gsum.rstrip(" + ") + " <= " + str(h[i]) + "\n"
              )
      totalconstraints = ineqstring + eqstring
      return totalconstraints
  
imports: from numpy import ndarray, asarray, any
  from mystic._symbolic import solve
  from mystic.tools import list_or_tuple_or_ndarray, flatten
label_desc: Use image node_id 1 for calling a global function with example usage: linear_symbolic(A, b, G, h, variables) and returns: totalconstraints