code: def _should_skip_xfail_test_sample(
      op_name: str,
      variant_test_name: str,
      sample,
      model_type: pytorch_test_common.TorchModelType,
  ) -> Tuple[Optional[str], Optional[str]]:
      """Check if the test sample should be skipped or xfailed.
  
      If the xfail/skip decorator meta is matched with its op_name and model_type,
      return the test_behavior and reason. Otherwise, return None, None. Note that
      if the matcher is None, the test is decorator_meta is meant to skip/xfail all model types.
  
      Args:
          op_name: The name of the op.
          sample: The test sample.
          model_type: The model type of the test.
  
      Returns:
          A tuple of (test_behavior, reason). test_behavior is either "skip" or "xfail".
          reason is the reason for the test_behavior.
      """
  
      if op_name not in OP_WITH_SKIPPED_XFAIL_SUBTESTS:
          return None, None
      for decorator_meta in SKIP_XFAIL_SUBTESTS:
          # Linear search on ops_test_data.SKIP_XFAIL_SUBTESTS. That's fine because the list is small.
          # NOTE: If model_type is None, the test is decorator_meta is meant to skip/xfail all model types.
          if (
              decorator_meta.op_name == op_name
              and decorator_meta.variant_name == variant_test_name
          ) and (
              model_type == decorator_meta.model_type
              or decorator_meta.model_type is None
          ):
              if (
                  decorator_meta.matcher is None
                  and decorator_meta.model_type is None
              ):
                  raise TypeError(
                      "Either Matcher or model_type must be defined in sub xfail and skip."
                  )
              if (
                  decorator_meta.matcher is not None
                  and decorator_meta.matcher(sample)
              ):
                  return (
                      decorator_meta.test_behavior,
                      decorator_meta.reason,
                  )
              elif decorator_meta.matcher is None:
                  # xfail/skip the whole test of the model type without matcher
                  return (
                      decorator_meta.test_behavior,
                      decorator_meta.reason,
                  )
      return None, None
  
imports: from __future__ import annotations
  import copy
  import itertools
  from typing import Any, Callable, Collection, Mapping, Optional, Tuple, Type, Union
  import onnx_test_common
  import parameterized
  import pytest
  import pytorch_test_common
  import torch
  from onnx_test_common import skip, skip_slow, xfail
  from torch.onnx._internal.diagnostics import _rules
  from torch.testing._internal import common_device_type, common_methods_invocations, common_utils
  from torch.testing._internal.opinfo import core
label_desc: Use image node_id 3 for calling a global function with example usage: _should_skip_xfail_test_sample(op_name, variant_test_name, sample, model_type) and returns: None,  None, None,  None, decorator_meta,  decorator_meta, decorator_meta,  decorator_meta