code: def get_matcher_loss_func(
      data_format: str,
      problem_type: str,
      loss_type: Optional[str] = None,
      pos_margin: Optional[float] = None,
      neg_margin: Optional[float] = None,
      distance_type: Optional[str] = None,
  ):
      """
      Return a list of pytorch metric learning's loss functions based on their names.
  
      Parameters
      ----------
      data_format
          The training data format, e.g., pair or triplet.
      problem_type
          Type of problem.
      loss_type
          The provided loss type.
      pos_margin
          The positive margin in computing the metric learning loss.
      neg_margin
          The negative margin in computing the metric learning loss.
      distance_type
          The distance function type.
  
      Returns
      -------
      A loss function of metric learning.
      """
  
      allowable_loss_types = infer_matcher_loss(
          data_format=data_format, problem_type=problem_type
      )
      if loss_type is not None:
          assert (
              loss_type in allowable_loss_types
          ), f"data format {data_format} can't use loss {loss_type}."
      else:
          loss_type = allowable_loss_types[0]
  
      if loss_type.lower() == CONTRASTIVE_LOSS:
          return losses.ContrastiveLoss(
              pos_margin=pos_margin,
              neg_margin=neg_margin,
              distance=get_metric_learning_distance_func(distance_type),
          )
      elif loss_type.lower() == MULTI_NEGATIVES_SOFTMAX_LOSS:
          return MultiNegativesSoftmaxLoss(
              local_loss=True,
              gather_with_grad=True,
              cache_labels=False,
          )
      else:
          raise ValueError(f"Unknown metric learning loss: {loss_type}")
  
imports: import functools
  import logging
  import re
  import warnings
  from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
  import torchmetrics
  from omegaconf import DictConfig, OmegaConf
  from packaging import version
  from pytorch_metric_learning import distances, losses, miners
  from torch import nn, optim
  from torch.nn import functional
  from torchmetrics.detection.mean_ap import MeanAveragePrecision
  from transformers import Adafactor
  from transformers.models.mask2former.modeling_mask2former import Mask2FormerConfig, Mask2FormerLoss
  from transformers.trainer_pt_utils import get_parameter_names
  from ..constants import ACC, ACCURACY, AVERAGE_PRECISION, BER, BINARY, BIT_FIT, COLUMN_FEATURES, CONTRASTIVE_LOSS, COSINE_EMBEDDING_LOSS, COSINE_SIMILARITY, CROSS_ENTROPY, DETECTION_METRICS, DIRECT_LOSS, EM, F1, F1_MACRO, F1_MICRO, F1_WEIGHTED, FEATURES, FEW_SHOT_CLASSIFICATION, FM, HIT_RATE, IA3, IA3_BIAS, IA3_LORA, IA3_LORA_BIAS, IA3_LORA_NORM, IA3_NORM, IOU, LOG_LOSS, LORA, LORA_BIAS, LORA_NORM, MAE, MULTI_NEGATIVES_SOFTMAX_LOSS, MULTICLASS, NER, NER_TOKEN_F1, NORM_FIT, OBJECT_DETECTION, OPEN_VOCABULARY_OBJECT_DETECTION, OVERALL_ACCURACY, PAIR_MARGIN_MINER, PEARSONR, PEFT_STRATEGIES, QUADRATIC_KAPPA, R2, RECALL, REGRESSION, RMSE, ROC_AUC, ROOT_MEAN_SQUARED_ERROR, SEMANTIC_SEGMENTATION, SM, SPEARMANR
  from .losses import BBCEWithLogitLoss, FocalLoss, MultiNegativesSoftmaxLoss, SoftTargetCrossEntropy, StructureLoss
  from .lr_scheduler import get_cosine_schedule_with_warmup, get_linear_schedule_with_warmup, get_polynomial_decay_schedule_with_warmup
  from .semantic_seg_metrics import COD_METRICS_NAMES, Balanced_Error_Rate, Binary_IoU, Multiclass_IoU
label_desc: Use image node_id 16 for calling a global function with example usage: get_matcher_loss_func(data_format, problem_type, loss_type, pos_margin, neg_margin, distance_type) and returns: losses, MultiNegativesSoftmaxLoss