code: def topology_rank(topology):
      # Deserialize the Topology proto, if it is a string.
      if isinstance(topology, bytes):
          topology = Topology(serialized=topology)
  
      if not isinstance(topology, Topology):
          raise ValueError(
              "`topology` is not a Topology object; got {}".format(
                  type(topology)
              )
          )
  
      return len(topology.mesh_shape)
  
file_path: mesh/mesh_tensorflow/utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import contextlib
  import heapq
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow.python.framework import ops
  from tensorflow.python.tpu.topology import Topology
label_desc: Use image node_id 3 for calling a global function with example usage: topology_rank(topology) and returns: len