code: def _prefer_static_rank(tensor):
      """Returns the static rank if fully specified else the dynamic rank."""
      tensor = tf.convert_to_tensor(tensor)
      if tensor.shape.rank is None:
          return tf.rank(tensor)
      return tensor.shape.rank
  
file_path: tf-quant-finance/tf_quant_finance/models/legacy/brownian_motion.py
imports: import tensorflow.compat.v2
  from tf_quant_finance.math.random_ops import multivariate_normal
  from tf_quant_finance.models.legacy import brownian_motion_utils
  from tf_quant_finance.models.legacy import ito_process
label_desc: Use image node_id 2 for calling a global function with example usage: _prefer_static_rank(tensor) and returns: tensor, tf