code: def _precompute_metric_params(
      X, Y, xp, metric=None, **kwds
  ):  # pragma: no cover
      """Precompute data-derived metric parameters if not provided"""
      if metric == "seuclidean" and "V" not in kwds:
          if X is Y:
              V = xp.var(X, axis=0, ddof=1)
          else:
              V = xp.var(xp.vstack([X, Y]), axis=0, ddof=1)
          return {"V": V}
      if metric == "mahalanobis" and "VI" not in kwds:
          if X is Y:
              VI = xp.linalg.inv(xp.cov(X.T)).T
          else:
              VI = xp.linalg.inv(xp.cov(xp.vstack([X, Y]).T)).T
          return {"VI": VI}
      return {}
  
imports: from functools import partial
  import numpy
  from ....None import opcodes
  from ....None import options
  from ....core import recursive_tile
  from ....core.operand import OperandStage
  from ....serialization.serializables import KeyField, BoolField, DictField, Int64Field, AnyField
  from ....tensor.core import TensorOrder
  from ....tensor.merge import TensorConcatenate
  from ....tensor.array_utils import as_same_device, device, get_array_module
  from ....utils import has_unknown_shape, ensure_own_data
  from ...utils import gen_batches, get_chunk_n_rows
  from ...utils.validation import _num_samples
  from .core import PairwiseDistances
label_desc: Use image node_id 1 for calling a global function with example usage: _precompute_metric_params(X, Y, xp, metric) and returns: dict, dict, dict