code: def _select_weighted_metric(mstr, kwargs, out):
      kwargs = dict(kwargs)
  
      if "w" in kwargs and kwargs["w"] is None:
          # w=None is the same as omitting it
          kwargs.pop("w")
  
      if mstr.startswith("test_") or mstr in _METRICS["wminkowski"].aka:
          # These support weights
          pass
      elif "w" in kwargs:
          if (
              mstr in _METRICS["seuclidean"].aka
              or mstr in _METRICS["mahalanobis"].aka
          ):
              raise ValueError(
                  "metric %s incompatible with weights" % mstr
              )
  
          # XXX: C-versions do not support weights
          # need to use python version for weighting
          kwargs["out"] = out
          mstr = "test_%s" % mstr
  
      return mstr, kwargs
  
imports: from __future__ import division, print_function, absolute_import
  import warnings
  import numpy
  from functools import partial
  from collections import namedtuple
  from scipy._lib.six import callable, string_types
  from scipy._lib.six import xrange
  from scipy._lib._util import _asarray_validated
  from .None import _distance_wrap
  from .None import _hausdorff
  from ..linalg import norm
  from ..special import rel_entr
label_desc: Use image node_id 41 for calling a global function with example usage: _select_weighted_metric(mstr, kwargs, out) and returns: mstr,  kwargs