parameters: (nop_labels, rhs, n_bcast_dims)
return_statement: return g_labels, g_view, g_nout, g_count
docstring: Build the global view, which is a layout of all dimension labels
      plus an index table that maps from the layout to the dimensions
      in each operand. In the global view, the dimensions are arranged
      such that output ones are put on the left and contraction ones
      are put on the right.  
  
      Parameters
      ----------
      nop_labels:
          The input full label strings of all input operands
      rhs:
          The equation right hand side
      n_bcast_dims:
          The maxium number of broadcast dimensions
      
      Returns
      -------
      A tuple of g_labels, g_view, g_nout, g_count
      g_labels:
          the layout of all labels in a string
      g_view:
          the index table
      g_nout:
          the number of output dimensions
      g_count:
          the counter array for dimension contractions
docstring_summary: Build the global view, which is a layout of all dimension labels
      plus an index table that maps from the layout to the dimensions
      in each operand. In the global view, the dimensions are arranged
      such that output ones are put on the left and contraction ones
      are put on the right.
docstring_tokens: Build the global view which is a layout of all dimension labels plus an index table that maps from the layout to the dimensions in each operand . In the global view the dimensions are arranged such that output ones are put on the left and contraction ones are put on the right .
function: def build_global_view(nop_labels, rhs, n_bcast_dims):
      '''
      Build the global view, which is a layout of all dimension labels
      plus an index table that maps from the layout to the dimensions
      in each operand. In the global view, the dimensions are arranged
      such that output ones are put on the left and contraction ones
      are put on the right.  
  
      Parameters
      ----------
      nop_labels:
          The input full label strings of all input operands
      rhs:
          The equation right hand side
      n_bcast_dims:
          The maxium number of broadcast dimensions
      
      Returns
      -------
      A tuple of g_labels, g_view, g_nout, g_count
      g_labels:
          the layout of all labels in a string
      g_view:
          the index table
      g_nout:
          the number of output dimensions
      g_count:
          the counter array for dimension contractions
      '''
      # Put all labels in alphabetical order
      concat = sorted(''.join(nop_labels).replace('.', ''))
      labels, count = [], []
      for a, b in zip(['.'] + concat, concat):
          if a != b:
              labels.append(b)
              count.append(1)
          else:
              count[-1] += 1
  
      if rhs != None:
          validate_rhs(rhs, labels, n_bcast_dims)
          g_labels_out = rhs.replace('...', '.' * n_bcast_dims)
      else:
          g_labels_out = '.' * n_bcast_dims + ''.join(
              l for l, c in zip(labels, count) if c == 1)
  
      for i in range(len(count))[::-1]:
          if labels[i] in g_labels_out:
              labels.pop(i)
              count.pop(i)
  
      g_labels_sum = ''.join(labels)
      g_labels = g_labels_out + g_labels_sum
      g_view = list(map(lambda i: build_view(i, g_labels), nop_labels))
      g_nout = len(g_labels_out)
      g_count = count
  
      return g_labels, g_view, g_nout, g_count
function_tokens: def build_global_view ( nop_labels , rhs , n_bcast_dims ) : # Put all labels in alphabetical order concat = sorted ( '' . join ( nop_labels ) . replace ( '.' , '' ) ) labels , count = [ ] , [ ] for a , b in zip ( [ '.' ] + concat , concat ) : if a != b : labels . append ( b ) count . append ( 1 ) else : count [ - 1 ] += 1 if rhs != None : validate_rhs ( rhs , labels , n_bcast_dims ) g_labels_out = rhs . replace ( '...' , '.' * n_bcast_dims ) else : g_labels_out = '.' * n_bcast_dims + '' . join ( l for l , c in zip ( labels , count ) if c == 1 ) for i in range ( len ( count ) ) [ : : - 1 ] : if labels [ i ] in g_labels_out : labels . pop ( i ) count . pop ( i ) g_labels_sum = '' . join ( labels ) g_labels = g_labels_out + g_labels_sum g_view = list ( map ( lambda i : build_view ( i , g_labels ) , nop_labels ) ) g_nout = len ( g_labels_out ) g_count = count return g_labels , g_view , g_nout , g_count