//  [python]
def test_vector_norm(self, device, dtype):
        # This test compares torch.linalg.vector_norm's output with
        # torch.linalg.norm given a flattened tensor
        ord_vector = [0, 0.9, 1, 2, 3, inf, -0.5, -1, -2, -3, -inf]
        input_sizes = [
            (10, ),
            (4, 5),
            (3, 4, 5),
            (0, ),
            (0, 10),
            (0, 0),
            (10, 0, 10),
        ]

        def vector_norm_reference(input, ord, dim=None, keepdim=False, dtype=None):
            if dim is None:
                input_maybe_flat = input.flatten(0, -1)
            else:
                input_maybe_flat = input

            result = torch.linalg.norm(input_maybe_flat, ord, dim=dim, keepdim=keepdim, dtype=dtype)
            if keepdim and dim is None:
                result = result.reshape([1] * input.dim())
            return result

        def run_test_case(input, ord, dim, keepdim, norm_dtype):
            msg = f'input.size()={input.size()}, ord={ord}, dim={dim}, keepdim={keepdim}, dtype={dtype}, norm_dtype={norm_dtype}'
            error_msg = None
            if input.numel() == 0:
                if ord < 0:
                    error_msg = r'linalg.vector_norm of negative order cannot be performed on an empty tensor'
                elif ord == inf and (dim is None or input.size(dim) == 0):
                    error_msg = (
                        r'linalg.vector_norm cannot compute the infinity norm on an empty '
                        r'dimension because the operation does not have an identity')
            if error_msg is None:
                result_dtype_reference = vector_norm_reference(input, ord, dim=dim, keepdim=keepdim, dtype=norm_dtype)
                result_dtype = torch.linalg.vector_norm(input, ord, dim=dim, keepdim=keepdim, dtype=norm_dtype)
                self.assertEqual(result_dtype, result_dtype_reference, msg=msg)

                if norm_dtype is not None:
                    result_convert_before = torch.linalg.vector_norm(input.to(norm_dtype), ord, dim=dim, keepdim=keepdim)
                    if norm_dtype.is_complex:
                        result_convert_before = result_convert_before.to(norm_dtype)

                    result_out = torch.empty((0), dtype=norm_dtype, device=device)
                    torch.linalg.vector_norm(input, ord, dtype=norm_dtype, dim=dim, keepdim=keepdim, out=result_out)
                    self.assertEqual(result_convert_before, result_out, msg=msg)
                else:
                    result_out = torch.empty((0), dtype=result_dtype.dtype, device=device)
                    torch.linalg.vector_norm(input, ord, dim=dim, keepdim=keepdim, out=result_out)
                    self.assertEqual(result_dtype, result_out, msg=msg)
            else:
                with self.assertRaises(RuntimeError):
                    vector_norm_reference(input, ord, dim=dim, keepdim=keepdim)
                with self.assertRaisesRegex(RuntimeError, error_msg):
                    torch.linalg.vector_norm(input, ord, dim=dim, keepdim=keepdim)

        if dtype.is_complex:
            norm_dtypes = [None, torch.cfloat, torch.cdouble]
        else:
            norm_dtypes = [None, torch.float, torch.double, torch.cfloat, torch.cdouble, torch.float16, torch.bfloat16]

        for input_size, ord, keepdim, norm_dtype in product(input_sizes, ord_vector, [True, False], norm_dtypes):
            input = make_tensor(input_size, device, dtype, low=-9, high=9)
            for dim in [None, random.randint(0, len(input_size) - 1)]:
                run_test_case(
                    input,
                    ord,
                    dim,
                    keepdim,
                    norm_dtype)