code: def bmat(obj, ldict=None, gdict=None):
      """
      Build a matrix object from a string, nested sequence, or array.
  
      Parameters
      ----------
      obj : str or array_like
          Input data. If a string, variables in the current scope may be
          referenced by name.
      ldict : dict, optional
          A dictionary that replaces local operands in current frame.
          Ignored if `obj` is not a string or `gdict` is `None`.
      gdict : dict, optional
          A dictionary that replaces global operands in current frame.
          Ignored if `obj` is not a string.
  
      Returns
      -------
      out : matrix
          Returns a matrix object, which is a specialized 2-D array.
  
      See Also
      --------
      block :
          A generalization of this function for N-d arrays, that returns normal
          ndarrays.
  
      Examples
      --------
      >>> A = np.mat('1 1; 1 1')
      >>> B = np.mat('2 2; 2 2')
      >>> C = np.mat('3 4; 5 6')
      >>> D = np.mat('7 8; 9 0')
  
      All the following expressions construct the same block matrix:
  
      >>> np.bmat([[A, B], [C, D]])
      matrix([[1, 1, 2, 2],
              [1, 1, 2, 2],
              [3, 4, 7, 8],
              [5, 6, 9, 0]])
      >>> np.bmat(np.r_[np.c_[A, B], np.c_[C, D]])
      matrix([[1, 1, 2, 2],
              [1, 1, 2, 2],
              [3, 4, 7, 8],
              [5, 6, 9, 0]])
      >>> np.bmat('A,B; C,D')
      matrix([[1, 1, 2, 2],
              [1, 1, 2, 2],
              [3, 4, 7, 8],
              [5, 6, 9, 0]])
  
      """
      if isinstance(obj, str):
          if gdict is None:
              # get previous frame
              frame = sys._getframe().f_back
              glob_dict = frame.f_globals
              loc_dict = frame.f_locals
          else:
              glob_dict = gdict
              loc_dict = ldict
  
          return matrix(_from_string(obj, glob_dict, loc_dict))
  
      if isinstance(obj, (tuple, list)):
          # [[A,B],[C,D]]
          arr_rows = []
          for row in obj:
              if isinstance(row, N.ndarray):  # not 2-d
                  return matrix(concatenate(obj, axis=-1))
              else:
                  arr_rows.append(concatenate(row, axis=-1))
          return matrix(concatenate(arr_rows, axis=0))
      if isinstance(obj, N.ndarray):
          return matrix(obj)
  
imports: from __future__ import division, absolute_import, print_function
  import sys
  import warnings
  import ast
  import numpy.core.numeric
  from numpy.core.numeric import concatenate, isscalar
  from numpy.core.overrides import set_module
  from numpy.linalg import matrix_power
label_desc: Use image node_id 4 for calling a global function with example usage: bmat(obj, ldict, gdict) and returns: matrix, matrix, matrix, matrix