code: def _check_validate(op_info, sample):
      def _check_fail(sample):
          try:
              op_info(
                  sample.sample_input.input,
                  *sample.sample_input.args,
                  **sample.sample_input.kwargs,
              )
          except sample.error_type:
              pass
          except Exception as msg:
              raise AssertionError(  # noqa: TRY200
                  f"{op_info.name} on {sample.sample_input=} expected exception "
                  f"{sample.error_type}: {sample.error_regex}, got {type(msg).__name__}: {msg}"
              )
          else:
              raise AssertionError(
                  f"{op_info.name} on {sample.sample_input=} expected exception "
                  f"{sample.error_type}: {sample.error_regex}, got none."
              )
  
      def _check_success(sample):
          try:
              op_info(sample.input, *sample.args, **sample.kwargs)
          except Exception as msg:
              raise AssertionError(  # noqa: TRY200
                  f"{op_info.name} on {sample=} expected to succeed "
                  f", got {type(msg).__name__}: {msg}"
              )
  
      if isinstance(sample, ErrorInput):
          _check_fail(sample)
      else:
          _check_success(sample)
  
imports: import os
  import torch
  from torch.testing import make_tensor
  from torch.testing._internal.opinfo.core import BinaryUfuncInfo, ErrorInput, generate_elementwise_binary_tensors, ReductionOpInfo, sample_inputs_reduction, SampleInput
label_desc: Use image node_id 1 for calling a global function with example usage: _check_validate(op_info, sample) without return types