class_docstr: Validates potential Mesh TensorFlow layouts.
  
  Usage Example:
    mtf_graph = mtf.Graph()
    # Add operations to mtf_graph using Mesh TensorFlow.
    mesh_shape = mtf.Shape([("m1", 4), ("m2", 2)])
    layout_validator = valid_layouts.LayoutValidator(mtf_graph, mesh_shape)
  
    print(layout_validator.splittable_mtf_dimension_names)
    # Set of names of Mesh TensorFlow dimensions that may be assigned to mesh
    # dimensions.
  
    print(layout_validator.is_valid_assignment("batch", "m1"))
    # Whether the 'batch' Mesh TensorFlow dimension may be assigned to the 'm1'
    # mesh dimension. Unlike the previous method, this ensures that every
    # occurrence of the 'batch' dimension has a size that is evenly divisible by
    # the size of 'm1'.
  
  Attributes:
    splittable_mtf_dimension_names: a set(string) of the names of MTF dimensions
        that may be assigned in a layout.
    mesh_dimension_name_to_size: a {string: int}, mapping names of mesh
        dimensions to their size.
docstr: Initializer for self._mtf_dimension_name_to_size_gcd.
  
  Args:
    mtf_graph: an mtf.Graph.
  
  Returns:
    A {string: int}, mapping the name of an MTF dimension to the greatest
    common divisor of all the sizes it has. All these sizes being evenly
    divisible by some x is equivalent to the GCD being divisible by x.
docstr_tok: ["Initializer","for","self._mtf_dimension_name_to_size_gcd",".","Args",":","mtf_graph",":","an","mtf.Graph",".","Returns",":","A","{","string",":","int","}",",","mapping","the","name","of","an","MTF","dimension","to","the","greatest","common","divisor","of","all","the","sizes","it","has",".","All","these","sizes","being","evenly","divisible","by","some","x","is","equivalent","to","the","GCD","being","divisible","by","x","."]
code: def _initialize_mtf_dimension_name_to_size_gcd(self, mtf_graph):
      """Initializer for self._mtf_dimension_name_to_size_gcd.
  
      Args:
        mtf_graph: an mtf.Graph.
  
      Returns:
        A {string: int}, mapping the name of an MTF dimension to the greatest
        common divisor of all the sizes it has. All these sizes being evenly
        divisible by some x is equivalent to the GCD being divisible by x.
      """
      mtf_dimension_name_to_size_gcd = {}
      for mtf_operation in mtf_graph.operations:
          for mtf_tensor in mtf_operation.outputs:
              for mtf_dimension in mtf_tensor.shape.dims:
                  mtf_dimension_name_to_size_gcd[
                      mtf_dimension.name
                  ] = math.gcd(
                      mtf_dimension_name_to_size_gcd.get(
                          mtf_dimension.name, mtf_dimension.size
                      ),
                      mtf_dimension.size,
                  )
  
      return mtf_dimension_name_to_size_gcd
  
file_path: mesh/mesh_tensorflow/auto_mtf/valid_layouts.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import re
label_desc: Use image node_id 6 for calling the LayoutValidator obj's underlying member method code with example usage: obj._initialize_mtf_dimension_name_to_size_gcd(mtf_graph) and returns: mtf_dimension_name_to_size_gcd