code: def _rank(
      input, name=None
  ):  # pylint: disable=redefined-builtin,unused-argument
      if not hasattr(input, "shape"):
          input = (
              tf.convert_to_tensor(input)
              if tf.get_static_value(input) is None
              else np.array(input)
          )
      ndims_ = tensorshape_util.rank(getattr(input, "shape", None))
      return (
          tf.rank(input)
          if ndims_ is None
          else np.array(ndims_, np.int32)
      )
  
imports: import decorator
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal.backend import numpy
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import control_flow_case
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 17 for calling a global function with example usage: _rank(input, name) and returns: unknown