code: def _multi_dot_three(A, B, C):
      """
      Find best ordering for three arrays and do the multiplication.
  
      Doing in manually instead of using dynamic programing is
      approximately 15 times faster.
      """
      # cost1 = cost((AB)C)
      cost1 = (
          A.shape[0] * A.shape[1] * B.shape[1]
          + A.shape[0] * B.shape[1] * C.shape[1]  # (AB)
      )  # (--)C
      # cost2 = cost((AB)C)
      cost2 = (
          B.shape[0] * B.shape[1] * C.shape[1]
          + A.shape[0] * A.shape[1] * C.shape[1]  # (BC)
      )  # A(--)
  
      if cost1 < cost2:
          return _dot(_dot(A, B), C)
      else:
          return _dot(A, _dot(B, C))
  
imports: import warnings
  import numpy
  import pandas
  import patsy
  from scipy import sparse
  from scipy.stats.distributions import norm
  from statsmodels.base._penalties import Penalty
  import statsmodels.base.model
  from statsmodels.tools import data
  from statsmodels.tools.decorators import cache_readonly
  from statsmodels.tools.sm_exceptions import ConvergenceWarning
label_desc: Use image node_id 2 for calling a global function with example usage: _multi_dot_three(A, B, C) and returns: _dot, _dot