docs: def build_element(element, subscript_dict):
      """
      Returns a string that has processed a single element dictionary
      Parameters
      ----------
      element: dictionary
          dictionary containing at least the elements:
          - kind: ['constant', 'setup', 'component', 'lookup']
              Different types of elements will be built differently
          - py_expr: string
              An expression that has been converted already into python syntax
          - subs: list of lists
              Each sublist contains coordinates for initialization of a particular
              part of a subscripted function, the list of subscripts vensim attaches to an equation
  
      subscript_dict: dictionary
  
      Returns
      -------
  
      """
      if element['kind'] == 'constant':
          cache_type = "@cache('run')"
      elif element['kind'] in ['setup', 'stateful']:  # setups only get called once, caching is wasted
          cache_type = ''
      elif element['kind'] == 'component':
          cache_type = "@cache('step')"
      elif element['kind'] == 'stateful':
          cache_type = ''
      elif element['kind'] == 'lookup':  # lookups may be called with different values in a round
          cache_type = ''
      else:
          raise AttributeError("Bad value for 'kind'")
  
      if len(element['py_expr']) > 1:
          contents = 'return utils.xrmerge([%(das)s,])' % {'das': ',\n'.join(element['py_expr'])}
      else:
          contents = 'return %(py_expr)s' % {'py_expr': element['py_expr'][0]}
  
      indent = 8
      element.update({'cache': cache_type,
                      'ulines': '-' * len(element['real_name']),
                      'contents': contents.replace('\n',
                                                   '\n' + ' ' * indent)})  # indent lines 2 onward
      
      element['doc'] = element['doc'].replace('\\', '\n    ').encode('unicode-escape')
  
      if 'unit' in element:
          element['unit'] = element['unit'].encode('unicode-escape')
      if 'real_name' in element:
          element['real_name'] = element['real_name'].encode('unicode-escape')
      if 'eqn' in element:
          element['eqn'] = element['eqn'].encode('unicode-escape')
      
      if element['kind'] == 'stateful':
          func = '''
      %(py_name)s = %(py_expr)s
              ''' % {'py_name': element['py_name'], 'py_expr': element['py_expr'][0]}
  
      else:
          func = '''
      %(cache)s
      def %(py_name)s(%(arguments)s):
          """
          Real Name: %(real_name)s
          Original Eqn: %(eqn)s
          Units: %(unit)s
          Limits: %(lims)s
          Type: %(kind)s
  
          %(doc)s
          """
          %(contents)s
          ''' % element
  
      return func