code: def _get_sandwich_arrays(results, cov_type=""):
      """Helper function to get scores from results
  
      Parameters
      """
  
      if isinstance(results, tuple):
          # assume we have jac and hessian_inv
          jac, hessian_inv = results
          xu = jac = np.asarray(jac)
          hessian_inv = np.asarray(hessian_inv)
      elif hasattr(results, "model"):
          if hasattr(results, "_results"):
              # remove wrapper
              results = results._results
          # assume we have a results instance
          if hasattr(results.model, "jac"):
              xu = results.model.jac(results.params)
              hessian_inv = np.linalg.inv(
                  results.model.hessian(results.params)
              )
          elif hasattr(results.model, "score_obs"):
              xu = results.model.score_obs(results.params)
              hessian_inv = np.linalg.inv(
                  results.model.hessian(results.params)
              )
          else:
              xu = results.model.wexog * results.wresid[:, None]
  
              hessian_inv = np.asarray(results.normalized_cov_params)
  
          # experimental support for freq_weights
          if (
              hasattr(results.model, "freq_weights")
              and not cov_type == "clu"
          ):
              # we do not want to square the weights in the covariance calculations
              # assumes that freq_weights are incorporated in score_obs or equivalent
              # assumes xu/score_obs is 2D
              # temporary asarray
              xu /= np.sqrt(
                  np.asarray(results.model.freq_weights)[:, None]
              )
  
      else:
          raise ValueError(
              "need either tuple of (jac, hessian_inv) or results"
              + "instance"
          )
  
      return xu, hessian_inv
  
imports: import numpy
  from statsmodels.tools.grouputils import combine_indices, group_sums
  from statsmodels.stats.moment_helpers import se_cov
label_desc: Use image node_id 6 for calling a global function with example usage: _get_sandwich_arrays(results, cov_type) and returns: xu,  hessian_inv