code: def sample_inputs_linalg_norm(
      op_info, device, dtype, requires_grad, *, variant=None, **kwargs
  ):
      if variant is not None and variant not in (
          "subgradient_at_zero",
      ):
          raise ValueError(
              f"Unsupported variant, expected variant to be 'subgradient_at_zero' but got: {variant}"
          )
  
      test_sizes = [
          (S,),
          (0,),
          (S, S),
          (0, 0),
          (S, 0),
          (0, S),
          (S, S, S),
          (0, S, S),
          (S, 0, S),
          (0, 0, 0),
      ]
  
      vector_ords = (
          None,
          0,
          0.5,
          1,
          2,
          3.5,
          inf,
          -0.5,
          -1,
          -2,
          -3.5,
          -inf,
      )
      if dtype in {torch.float16, torch.bfloat16, torch.complex32}:
          # svdvals not supported for low precision dtypes
          matrix_ords = ("fro", inf, -inf, 1, -1)
      else:
          matrix_ords = (None, "fro", "nuc", inf, -inf, 1, -1, 2, -2)
  
      make_arg = partial(
          make_tensor,
          dtype=dtype,
          device=device,
          requires_grad=requires_grad,
          low=None,
          high=None,
      )
  
      for test_size in test_sizes:
          is_vector_norm = len(test_size) == 1
          is_matrix_norm = len(test_size) == 2
  
          # IndexError: amax(): Expected reduction dim 0 to have non-zero size.
          is_valid_for_p2 = is_vector_norm or (
              test_size[-1] != 0 and test_size[-2] != 0
          )
  
          for keepdim in [False, True]:
              if variant != "subgradient_at_zero" and is_valid_for_p2:
                  yield SampleInput(
                      make_arg(test_size), keepdim=keepdim
                  )
  
              if not (is_vector_norm or is_matrix_norm):
                  continue
  
              ords = vector_ords if is_vector_norm else matrix_ords
  
              for ord in ords:
                  if is_vector_norm and test_size[-1] == 0:
                      if ord == np.inf or (ord is not None and ord < 0):
                          # RuntimeError: linalg.vector_norm cannot compute the
                          # {ord} norm on an empty tensor because the operation
                          # does not have an identity
                          continue
                  elif is_matrix_norm:
                      dims_to_check = {
                          None: (0,),
                          np.inf: (0,),
                          2: (0, 1),
                          1: (1,),
                          -1: (1,),
                          -2: (0, 1),
                          -np.inf: (0,),
                      }.get(ord, ())
  
                      if any(test_size[d] == 0 for d in dims_to_check):
                          # IndexError: amax(): Expected reduction dim {dim} to
                          # have non-zero size.
                          continue
  
                  if variant == "subgradient_at_zero":
                      yield SampleInput(
                          torch.zeros(
                              test_size,
                              dtype=dtype,
                              device=device,
                              requires_grad=requires_grad,
                          ),
                          ord,
                          keepdim=keepdim,
                      )
                  else:
                      yield SampleInput(
                          make_arg(test_size), ord, keepdim=keepdim
                      )
  
                      if ord in ["nuc", "fro"]:
                          yield SampleInput(
                              make_arg(test_size),
                              ord=ord,
                              keepdim=keepdim,
                              dim=(0, 1),
                          )
  
imports: import itertools
  import random
  import unittest
  from functools import partial
  from itertools import chain, product
  from typing import Iterable, List, Tuple
  import numpy
  from numpy import inf
  import torch
  from torch.testing import make_tensor
  from torch.testing._internal.common_cuda import _get_magma_version, _get_torch_cuda_version, with_tf32_off
  from torch.testing._internal.common_device_type import has_cusolver, skipCPUIfNoLapack, skipCUDAIf, skipCUDAIfNoCusolver, skipCUDAIfNoMagma, skipCUDAIfNoMagmaAndNoCusolver, skipCUDAIfNoMagmaAndNoLinalgsolver, skipCUDAIfRocm, tol, toleranceOverride
  from torch.testing._internal.common_dtype import all_types_and_complex, all_types_and_complex_and, floating_and_complex_types, floating_and_complex_types_and, get_all_complex_dtypes
  from torch.testing._internal.common_utils import GRADCHECK_NONDET_TOL, IS_MACOS, make_fullrank_matrices_with_distinct_singular_values, skipIfSlowGradcheckEnv, slowTest, TEST_WITH_ROCM
  from torch.testing._internal.opinfo.core import clone_sample, DecorateInfo, ErrorInput, gradcheck_wrapper_hermitian_input, L, M, OpInfo, ReductionOpInfo, S, SampleInput
  from torch.testing._internal.opinfo.refs import PythonRefInfo, ReductionPythonRefInfo
label_desc: Use image node_id 12 for calling a global function with example usage: sample_inputs_linalg_norm(op_info, device, dtype, requires_grad) without return types