code: def _parse_dist_kw(dist, enforce_subclass=True):
      """Parse `dist` keyword.
  
      Parameters
      ----------
      dist : str or stats.distributions instance.
          Several functions take `dist` as a keyword, hence this utility
          function.
      enforce_subclass : bool, optional
          If True (default), `dist` needs to be a
          `_distn_infrastructure.rv_generic` instance.
          It can sometimes be useful to set this keyword to False, if a function
          wants to accept objects that just look somewhat like such an instance
          (for example, they have a ``ppf`` method).
  
      """
      if isinstance(dist, rv_generic):
          pass
      elif isinstance(dist, str):
          try:
              dist = getattr(distributions, dist)
          except AttributeError as e:
              raise ValueError(
                  "%s is not a valid distribution name" % dist
              ) from e
      elif enforce_subclass:
          msg = (
              "`dist` should be a stats.distributions instance or a string "
              "with the name of such a distribution."
          )
          raise ValueError(msg)
  
      return dist
  
imports: from __future__ import annotations
  import math
  import warnings
  from collections import namedtuple
  import numpy
  from numpy import isscalar, r_, log, around, unique, asarray, zeros, arange, sort, amin, amax, atleast_1d, sqrt, array, compress, pi, exp, ravel, count_nonzero, sin, cos, arctan2, hypot
  from scipy import optimize
  from scipy import special
  from .None import statlib
  from .None import stats
  from .stats import find_repeats, _contains_nan, _normtest_finish
  from .contingency import chi2_contingency
  from .None import distributions
  from ._distn_infrastructure import rv_generic
  from ._hypotests import _get_wilcoxon_distr
label_desc: Use image node_id 6 for calling a global function with example usage: _parse_dist_kw(dist, enforce_subclass) and returns: dist