code: def _get_axis_and_p(draw):
      p = draw(
          st.sampled_from(
              ["fro", "nuc", 1, 2, -1, -2, float("inf"), -float("inf")]
          )
      )
      if p in ["fro", "nuc"]:
          max_axes_size = 2
          min_axes_size = 2
      else:
          min_axes_size = 1
          max_axes_size = 5
      x_dtype, values, axis = draw(
          helpers.dtype_values_axis(
              available_dtypes=helpers.get_dtypes("valid"),
              min_num_dims=2,
              valid_axis=True,
              min_value=-1e04,
              max_value=1e04,
              min_axes_size=min_axes_size,
              max_axes_size=max_axes_size,
              large_abs_safety_factor=2,
              safety_factor_scale="log",
          )
      )
      axis = (
          axis[0]
          if isinstance(axis, tuple) and len(axis) == 1
          else axis
      )
      # ToDo: fix the castable dtype helper. Right now using `dtype` causes errors
      #  dtype should be real for real inputs, but got ComplexDouble
      x_dtype, values, dtype = draw(
          helpers.get_castable_dtype(
              draw(helpers.get_dtypes("valid")), x_dtype[0], values[0]
          )
      )
      return p, x_dtype, values, axis, x_dtype
  
imports: import math
  import sys
  import numpy
  from hypothesis import strategies, assume
  import ivy
  import ivy_tests.test_ivy.helpers
  from ivy_tests.test_ivy.helpers import assert_all_close
  from ivy_tests.test_ivy.helpers import handle_frontend_test
  from ivy_tests.test_ivy.test_frontends.test_torch.test_miscellaneous_ops import dtype_value1_value2_axis
  from ivy_tests.test_ivy.helpers.hypothesis_helpers.general_helpers import matrix_is_stable
  from ivy_tests.test_ivy.test_functional.test_core.test_linalg import _matrix_rank_helper
label_desc: Use image node_id 2 for calling a global function with example usage: _get_axis_and_p(draw) and returns: p,  x_dtype,  values,  axis,  x_dtype