class_docstr: Represents a Mesh configuration over a certain list of Mesh Dimensions.
  
  A mesh consists of named dimensions with sizes, which describe how a set of
  devices are arranged. Defining tensor layouts in terms of mesh dimensions
  allows us to efficiently determine the communication required when computing
  an operation with tensors of different layouts.
  
  A mesh provides information not only about the placement of the tensors but
  also the topology of the underlying devices. For example, we can group 8 TPUs
  as a 1-D array for data parallelism or a `2x4` grid for (2-way) data
  parallelism and (4-way) model parallelism.
  
  Refer to [DTensor Concepts](https://www.tensorflow.org/guide/dtensor_overview)
  for in depth discussion and examples.
  
  Note: the utilities `dtensor.create_mesh` and
  `dtensor.create_distributed_mesh` provide a simpler API to create meshes for
  single- or multi-client use cases.
class_docstr_tok: ["Represents","a","Mesh","configuration","over","a","certain","list","of","Mesh","Dimensions",".","A","mesh","consists","of","named","dimensions","with","sizes",",","which","describe","how","a","set","of","devices","are","arranged",".","Defining","tensor","layouts","in","terms","of","mesh","dimensions","allows","us","to","efficiently","determine","the","communication","required","when","computing","an","operation","with","tensors","of","different","layouts",".","A","mesh","provides","information","not","only","about","the","placement","of","the","tensors","but","also","the","topology","of","the","underlying","devices",".","For","example",",","we","can","group","8","TPUs","as","a","1-D","array","for","data","parallelism","or","a","`","2x4","`","grid","for","(","2-way",")","data","parallelism","and","(","4-way",")","model","parallelism",".","Refer","to","[","DTensor","Concepts","]","(","https",":","\/\/www.tensorflow.org\/guide\/dtensor_overview",")","for","in","depth","discussion","and","examples",".","Note",":","the","utilities","`","dtensor.create_mesh","`","and","`","dtensor.create_distributed_mesh","`","provide","a","simpler","API","to","create","meshes","for","single-","or","multi-client","use","cases","."]
docstr: Returns a dictionary from device ID to {dim_name: dim_index}.
  
  For example, for a 3x2 mesh, return this:
  
  ```
    { 0: {'x': 0, 'y', 0},
      1: {'x': 0, 'y', 1},
      2: {'x': 1, 'y', 0},
      3: {'x': 1, 'y', 1},
      4: {'x': 2, 'y', 0},
      5: {'x': 2, 'y', 1} }
  ```
docstr_tok: ["Returns","a","dictionary","from","device","ID","to","{","dim_name",":","dim_index","}",".","For","example",",","for","a","3x2","mesh",",","return","this",":","``","`","{","0",":","{","'","x","'",":","0",",","'","y","'",",","0","}",",","1",":","{","'","x","'",":","0",",","'","y","'",",","1","}",",","2",":","{","'","x","'",":","1",",","'","y","'",",","0","}",",","3",":","{","'","x","'",":","1",",","'","y","'",",","1","}",",","4",":","{","'","x","'",":","2",",","'","y","'",",","0","}",",","5",":","{","'","x","'",":","2",",","'","y","'",",","1","}","}","``","`"]
code: def unravel_index(self):
      """Returns a dictionary from device ID to {dim_name: dim_index}.
  
      For example, for a 3x2 mesh, return this:
  
      ```
        { 0: {'x': 0, 'y', 0},
          1: {'x': 0, 'y', 1},
          2: {'x': 1, 'y', 0},
          3: {'x': 1, 'y', 1},
          4: {'x': 2, 'y', 0},
          5: {'x': 2, 'y', 1} }
      ```
      """
      idx_ranges = [
          range(self.dim_size(dim_name)) for dim_name in self.dim_names
      ]
      mesh_pos = itertools.product(*idx_ranges)
      mapping = {}
      for device_id, device_pos in enumerate(mesh_pos):
          device_loc = {}
          for dim_name, dim_index in zip(self.dim_names, device_pos):
              device_loc[dim_name] = dim_index
          mapping[device_id] = device_loc
      return mapping
  
imports: import collections
  import functools
  import itertools
  from typing import List, Dict, Optional, Union
  import numpy
  from tensorflow.dtensor.proto import layout_pb2
  from tensorflow.python import _pywrap_dtensor_device
  from tensorflow.python.framework import device
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 17 for calling the Mesh obj's underlying member method code with example usage: obj.unravel_index() and returns: mapping