class_docstr: One kind of mapping of a logical mesh to a physical mesh.
class_docstr_tok: ["One","kind","of","mapping","of","a","logical","mesh","to","a","physical","mesh","."]
docstr: Compute mesh shape even without knowing the physical shape.
  
  This is useful in cases where the mesh shape must be computed before
  you know the physical_shape.
  
  Args:
    spec: a list of (string, list-of-integers) pairs
    num_processors: an integer
  Returns:
    a mtf.Shape
code: def spec_to_mesh_shape(cls, spec, num_processors):
      """Compute mesh shape even without knowing the physical shape.
  
      This is useful in cases where the mesh shape must be computed before
      you know the physical_shape.
  
      Args:
        spec: a list of (string, list-of-integers) pairs
        num_processors: an integer
      Returns:
        a mtf.Shape
      """
      logical_ndims = len(spec)
      names = [p[0] for p in spec]
      sizes = [p[1] for p in spec]
      sizes = [
          None if s is None else mtf.list_product(s) for s in sizes
      ]
      if logical_ndims > 0 and sizes[0] is None:
          sizes[0] = num_processors // mtf.list_product(sizes[1:])
      if mtf.list_product(sizes) != num_processors:
          raise ValueError(
              "product of spec must be num_processors"
              " spec=%s num_processors=%s" % (spec, num_processors)
          )
      return mtf.Shape(
          [mtf.Dimension(name, s) for name, s in zip(names, sizes)]
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import os
  import gin
  from mesh_tensorflow import ops_with_redefined_builtins
  from mesh_tensorflow import tpu_variables
  from mesh_tensorflow import utils
  from six.moves import xrange
  import tensorflow.compat.v1
  from tensorflow.python.tpu.ops import tpu_ops
label_desc: Use image node_id 4 for calling the HierarchicalTiling obj's underlying member method code with example usage: obj.spec_to_mesh_shape(cls, spec, num_processors) and returns: mtf