code: def _lstm_cell_builder(op, x, h_prev, cs_prev, before_op=None):
      b = op.bias  # [4*hidden_dim]
      forget_bias = op.forget_bias.val  # python:float
  
      # xh = [x, h_prev]
      # xh shape: [b, input_dim+hidden_dim]
      xh = mb.concat(values=[x, h_prev], axis=-1, before_op=before_op)
  
      # w: [4*hidden_dim, input_dim + hidden_dim] (icfo layout)
      w = np.transpose(op.weight.val)
      # [i, ci, f, o] = xh * w + b. Shape is [b, 4*hidden_dim]
      icfo = mb.linear(x=xh, weight=w, bias=b, before_op=before_op)
  
      # i, ci, f, o shape: [b, hidden_dim]
      i, ci, f, o = mb.split(
          x=icfo, num_splits=4, axis=-1, before_op=before_op
      )
      if op.forget_bias.val != 0:
          f = mb.add(x=f, y=forget_bias, before_op=before_op)
  
      # i = sigmoid(cs_prev .* wci + i)
      # f = sigmoid(cs_prev .* wcf + f)
      if op.use_peephole.val:
          wci = op.weight_peep_i.val  # [hidden_dim]
          wcf = op.weight_peep_f.val  # [hidden_dim]
  
          x = mb.mul(x=cs_prev, y=wci, before_op=before_op)
          pre_i = mb.add(x=x, y=i, before_op=before_op)
  
          x = mb.mul(x=cs_prev, y=wcf, before_op=before_op)
          pre_f = mb.add(x=x, y=f, before_op=before_op)
      else:
          pre_i = i
          pre_f = f
  
      i = mb.sigmoid(x=pre_i, before_op=before_op)
      f = mb.sigmoid(x=pre_f, before_op=before_op)
  
      # ci = tanh(ci)
      ci = mb.tanh(x=ci, before_op=before_op)
  
      # cs = ci .* i + cs_prev .* f
      x = mb.mul(x=ci, y=i, before_op=before_op)
      y = mb.mul(x=cs_prev, y=f, before_op=before_op)
      cs = mb.add(x=x, y=y, before_op=before_op)
  
      # cs = clip(cs, cell_clip)
      if op.cell_clip is not None:
          clip_val = op.cell_clip.val
          cs = mb.clip(
              x=cs, alpha=-clip_val, beta=clip_val, before_op=before_op
          )
  
      # o = sigmoid(cs * wco + o)
      if op.use_peephole.val:
          wco = op.weight_peep_o.val
          x = mb.mul(x=cs, y=wco, before_op=before_op)
          pre_o = mb.add(x=x, y=o, before_op=before_op)
      else:
          pre_o = o
      o = mb.sigmoid(x=pre_o, before_op=before_op)
  
      # co = tanh(cs)
      co = mb.tanh(x=cs, before_op=before_op)
  
      # h = co .* o
      h = mb.mul(x=co, y=o, before_op=before_op)
  
      return [i, cs, f, o, ci, co, h]
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/frontend/tensorflow/ssa_passes/expand_tf_lstm.py
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  from coremltools.converters.mil.mil.passes.pass_registry import register_pass
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import types
  import numpy
  import logging
label_desc: Use image node_id 3 for calling a global function with example usage: _lstm_cell_builder(op, x, h_prev, cs_prev, before_op) and returns: list