code: def get_coef_dict(tb, str_expr=None, ref_coef_dict=None, axis="rows"):
      r"""Gets either col or row fields matching `str_expr` and take intersection
      with keys in coefficient reference dict.
  
      Parameters
      ----------
      tb : :class:`.MatrixTable` or :class:`.Table`
          :class:`.MatrixTable` or :class:`.Table` containing row (or col) for `coef_dict`.
      str_expr : :class:`str`, optional
          String expression pattern to match against row (or col) fields. If left
          unspecified, the intersection of field names is only between existing
          row (or col) fields in `mt` and keys of `ref_coef_dict`.
      ref_coef_dict : :obj:`dict`, optional
          Reference coefficient dictionary with keys that are row (or col) field
          names from which to subset. If not included, coefficients are assumed to be 1.
      axis : :class:`str`
          Field type in which to search for field names. Options: 'rows', 'cols'
  
      Returns
      -------
      coef_dict : :obj:`dict`
          Coefficients to multiply each field. The coefficients are specified by
          `coef_dict` value, the row (or col) field name is specified by `coef_dict` key.
      """
      assert (
          str_expr is not None or ref_coef_dict is not None
      ), "str_expr and ref_coef_dict cannot both be None"
      assert (
          axis == "rows" or axis == "cols"
      ), "axis must be 'rows' or 'cols'"
      fields_to_search = (
          tb.row if axis == "rows" or isinstance(tb, Table) else tb.col
      )
      # when axis='rows' we're searching for annotations, axis='cols' searching for covariates
      axis_field = "annotation" if axis == "rows" else "covariate"
      if str_expr is None:
          # take all row (or col) fields in mt matching keys in coef_dict
          coef_dict = {
              k: ref_coef_dict[k]
              for k in ref_coef_dict.keys()
              if k in fields_to_search
          }
          # if intersect is empty: return error
          assert (
              len(coef_dict) > 0
          ), f"None of the keys in ref_coef_dict match any {axis[:-1]} fields"
          return coef_dict  # return subset of ref_coef_dict
      else:
          # str_expr search in list of row (or col) fields
          fields = [
              rf for rf in list(fields_to_search) if str_expr in rf
          ]
          assert (
              len(fields) > 0
          ), f"No {axis[:-1]} fields matched str_expr search: {str_expr}"
          if ref_coef_dict is None:
              print(f"Assuming coef = 1 for all {axis_field}s")
              return {k: 1 for k in fields}
          in_ref_coef_dict = set(fields).intersection(
              set(ref_coef_dict.keys())
          )  # fields in ref_coef_dict
          # if >0 fields returned by search are not in ref_coef_dict
          if in_ref_coef_dict != set(fields):
              # if none of the fields returned by search are in ref_coef_dict
              assert (
                  len(in_ref_coef_dict) > 0
              ), f"None of the {axis_field} fields in ref_coef_dict match search results"
              fields_to_ignore = set(fields).difference(
                  in_ref_coef_dict
              )
              print(
                  f"Ignored fields from {axis_field} search: {fields_to_ignore}"
              )
              print(
                  "To include ignored fields, change str_expr to match desired fields"
              )
              fields = list(in_ref_coef_dict)
          return {k: ref_coef_dict[k] for k in fields}
  
imports: import hail
  from hail.typecheck import typecheck, oneof, nullable
  from hail.expr.expressions import expr_float64, expr_int32, expr_array, expr_call
  from hail.matrixtable import MatrixTable
  from hail.table import Table
  from hail.utils.java import Env
  import numpy
  import pandas
  import scipy.stats
label_desc: Use image node_id 12 for calling a global function with example usage: get_coef_dict(tb, str_expr, ref_coef_dict, axis) and returns: coef_dict, unknown, unknown