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] = fractions.gcd(
              mtf_dimension_name_to_size_gcd.get(mtf_dimension.name,
                                                 mtf_dimension.size),
              mtf_dimension.size)

    return mtf_dimension_name_to_size_gcd