docs: def add_stock(identifier, subs, expression, initial_condition, subscript_dict):
      """
      Creates new model element dictionaries for the model elements associated
      with a stock.
  
      Parameters
      ----------
      identifier: basestring
          the python-safe name of the stock
  
      subs: list
          a list of subscript elements
  
      expression: basestring
          The formula which forms the derivative of the stock
  
      initial_condition: basestring
          Formula which forms the initial condition for the stock
  
      subscript_dict: dictionary
          Dictionary describing the possible dimensions of the stock's subscripts
  
      Returns
      -------
      reference: string
          a string to use in place of the 'INTEG...' pieces in the element expression string,
          a reference to the stateful object
      new_structure: list
  
          list of additional model element dictionaries. When there are subscripts,
          constructs an external 'init' and 'ddt' function so that these can be appropriately
          aggregated
  
      """
      new_structure = []
  
      if len(subs) == 0:
          stateful_py_expr = 'functions.Integ(lambda: %s, lambda: %s)' % (expression,
                                                                          initial_condition)
      else:
          stateful_py_expr = 'functions.Integ(lambda: _d%s_dt(), lambda: _init_%s())' % (identifier,
                                                                                         identifier)
  
          try:
              decoded = initial_condition.decode('unicode-escape')
              initial_condition_numeric = decoded.isnumeric()
          except AttributeError:
              # I believe this should be okay for Py3 but should be checked
              initial_condition_numeric = initial_condition.isnumeric()
  
          if subs and initial_condition_numeric:
              coords = utils.make_coord_dict(subs, subscript_dict, terse=False)
              dims = [utils.find_subscript_name(subscript_dict, sub) for sub in subs]
              shape = [len(coords[dim]) for dim in dims]
              initial_condition = textwrap.dedent("""\
                  xr.DataArray(data=np.ones(%(shape)s)*%(value)s,
                               coords=%(coords)s,
                               dims=%(dims)s )""" % {
                  'shape': shape,
                  'value': initial_condition,
                  'coords': repr(coords),
                  'dims': repr(dims)})
  
          # create the stock initialization element
          new_structure.append({
              'py_name': '_init_%s' % identifier,
              'real_name': 'Implicit',
              'kind': 'setup',  # not explicitly specified in the model file, but must exist
              'py_expr': initial_condition,
              'subs': subs,
              'doc': 'Provides initial conditions for %s function' % identifier,
              'unit': 'See docs for %s' % identifier,
              'lims': 'None',
              'eqn': 'None',
              'arguments': ''
          })
  
          new_structure.append({
              'py_name': '_d%s_dt' % identifier,
              'real_name': 'Implicit',
              'kind': 'component',
              'doc': 'Provides derivative for %s function' % identifier,
              'subs': subs,
              'unit': 'See docs for %s' % identifier,
              'lims': 'None',
              'eqn': 'None',
              'py_expr': expression,
              'arguments': ''
          })
  
      # describe the stateful object
      stateful = {
          'py_name': '_integ_%s' % identifier,
          'real_name': 'Representation of  %s' % identifier,
          'doc': 'Integrates Expression %s' % expression,
          'py_expr': stateful_py_expr,
          'unit': 'None',
          'lims': 'None',
          'eqn': 'None',
          'subs': '',
          'kind': 'stateful',
          'arguments': ''
      }
  
      new_structure.append(stateful)
      return "%s()" % stateful['py_name'], new_structure