code: def transform_args(request):
      """
      Allows for testing all metrics with <metric>(pred=key1,target=key2) registry format.
  
      Tests the following combinations:
          <metric>
          <metric>(pred=pred_key)
          <metric>(target=target_key)
          <metric>(pred=pred_key, target=target_key)
          <metric>(target=target_key, pred=pred_key)
      """
      param_keys = request.param
  
      def encapsulate_with_keys(
          metric_names, predictions, targets, extras=None
      ):
          if isinstance(metric_names, str):
              metric_names = [metric_names]
  
          pred_key = param_keys.get("pred", None)
          if pred_key:
              predictions = {pred_key: predictions}
  
          target_key = param_keys.get("target", None)
          if target_key:
              targets = {target_key: targets}
  
          # e.g. assuming param_keys = {"pred": "pred_key", "target": "target_key"} we will get:
          # {"pred": "pred_key", "target": "target_key"} -> ["pred=pred_key", "target=target_key"]
          # ["pred=pred_key", "target=target_key"] -> "(pred=pred_key,target=target_key)"
          params_str = ", ".join(
              [f"{key}={value}" for key, value in param_keys.items()]
          )
          if params_str:
              params_str = f"({params_str})"
              metric_names = [m + params_str for m in metric_names]
  
          return metric_names, (predictions, targets, extras)
  
      return encapsulate_with_keys
  
imports: from typing import Tuple
  import pytest
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: transform_args(request) and returns: encapsulate_with_keys, metric_names,  predictions,  targets,  extras