class_docstr: Tries to compute a good layout for Mesh Tensorflow.
  
  Given a mesh shape (see Mesh TensorFlow) and several operations, computes a
  good layout (a mapping from TensorFlow dimensions to mesh dimensions) using
  integer programming.
  
  More formally, suppose T is the set of TensorFlow dimensions and M is the set
  of mesh dimensions. A layout L is a map from (T) to (M union {"unassigned"}),
  designating which tensor dimensions are split using which mesh dimensions.
  
  We wish to compute a layout that minimizes memory usage. Unfortunately, the
  memory usage doesn't just depend on the layout, but also on how the scheduler
  orders operations; whenever an operation is being performed, there are other
  tensors in memory besides that operation's input and output tensors. The
  layout, however, affects the size of the various tensors in memory, as well as
  *the amount of temporary memory the operation uses*.
  
  With this in mind, our (boolean) integer program to minimize memory is:
  
  Variables:
    x_{t->m}: "global" (boolean) variables; takes a value of 1 if t in T is
        assigned to m in M, and a value of 0 otherwise.
    y_{assignment}: "local" (boolean) variables; for every set of TensorFlow
        dimensions used in an operation or tensor and for every (valid)
        assignment from that set of TF dimensions to (M union {"unassigned"}),
        we have one of these which takes a value of 1 if the global variables
        completely agree with that assignment and 0 otherwise.
    z: memory (continuous) variable; the peak memory usage.
  
  Constraints:
    Operation Constraints: for every operation, no two dimensions used in that
        operation can be mapped to the same mesh dimension (since doing so would
        cause some of its computation to be skipped entirely).
    Global Constraints: we enforce that every TensorFlow dimension is assigned
        to at most one mesh dimension (it may be unassigned).
    (Optional) Divisibility Constraints: we enforce that a TensorFlow dimension
        can only be assigned to a mesh dimension if the latter's size evenly
        divides the former's size.
    Local Constraints: we enforce that out of all assignments that share a
        domain (i.e. set of TensorFlow dimensions), exactly one is chosen.
    Global-to-Local Constraints: we enforce that assignment(t) = m, then
        x_{t->m} must be 1 for y_{assignment} to be 1. We also enforce that if
        assignment(t) = "unassigned", then x_{t->m} must be 0 for all m in M.
    Memory Constraints: for every operation i, the peak memory usage z must be
        least the memory usage during that operation. The latter can be derived
        from memory_contents[i] and the local variables relevant to those
        tensors (their new sizes) and to the operation (temporary memory
        needed).
  
  Objective Function:
    We want to minimize the variable z. However, we want to tiebreak by the
    number of assigned dimensions (preferring more dimensions), so our
    modified objective is (#MTF Dimensions + 1) * z - sum x_{t->m}. Note that we
    prefer more splitting because in general splits result in smaller tensors
    and less duplicated work.
docstr: Solves the current integer program and returns the computed layout.
  
  Args:
    print_solution: An optional boolean indicating whether to print the full
      solution in human-readable format.
  
  Returns:
    The computed layout (as a string).
  
  Raises:
    SolverError: the internal solver could not find a solution, or the
        solution found is infeasible.
docstr_tok: ["Solves","the","current","integer","program","and","returns","the","computed","layout",".","Args",":","print_solution",":","An","optional","boolean","indicating","whether","to","print","the","full","solution","in","human-readable","format",".","Returns",":","The","computed","layout","(","as","a","string",")",".","Raises",":","SolverError",":","the","internal","solver","could","not","find","a","solution",",","or","the","solution","found","is","infeasible","."]
code: def solve(self, print_solution=False):
      """Solves the current integer program and returns the computed layout.
  
      Args:
        print_solution: An optional boolean indicating whether to print the full
          solution in human-readable format.
  
      Returns:
        The computed layout (as a string).
  
      Raises:
        SolverError: the internal solver could not find a solution, or the
            solution found is infeasible.
      """
      # Solve and see how well the solver did.
      self._cp_solver = cp_model.CpSolver()
      status = self._cp_solver.Solve(self._model)
      if status != cp_model.OPTIMAL:
          if status == cp_model.FEASIBLE:
              logging.warning(
                  "A potentially suboptimal solution was found."
              )
          else:
              logging.error("Solver returned status %d.", status)
              raise SolverError(
                  "The solver could not solve the problem and returned "
                  "status {}.".format(status)
              )
  
      # TODO(joshuawang): Verify the solver's solution.
      if print_solution:
          print_cp_model_solution.print_solution(
              self._model, self._cp_solver
          )
  
      # Reconstruct layout from solution.
      layout = []
      for (
          mtf_dimension_name
      ) in self._layout_validator.splittable_mtf_dimension_names:
          for (
              mesh_dimension_name
          ) in self._layout_validator.mesh_dimension_name_to_size:
              value = self._cp_solver.Value(
                  self._global_vars[
                      (mtf_dimension_name, mesh_dimension_name)
                  ]
              )
              if value:  # Value is integer.
                  layout.append(
                      mtf_dimension_name + ":" + mesh_dimension_name
                  )
  
      layout.sort()
      return ";".join(layout)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import itertools
  from absl import logging
  from mesh_tensorflow.auto_mtf import print_cp_model_solution
  from mesh_tensorflow.auto_mtf import scheduler
  import six
  from ortools.sat.python import cp_model
label_desc: Use image node_id 7 for calling the LayoutOptimizer obj's underlying member method code with example usage: obj.solve(print_solution) and returns: str