code: def assert_same_rank(self, other):
          
          other = as_shape(other)
          if self.ndims is not None and other.ndims is not None:
              if self.ndims != other.ndims:
                  raise ValueError(
                      "Shapes %s and %s must have the same rank" % (self, other)
                  )
docs: Raises an exception if `self` and `other` do not have convertible ranks.
  
          Args:
            other: Another `TensorShape`.
  
          Raises:
            ValueError: If `self` and `other` do not represent shapes with the
              same rank.