class_docstr: The abstract dist sparse optimizer.
  
  Note: dgl dist sparse optimizer only work with dgl.distributed.DistEmbedding
  
  Parameters
  ----------
  params : list of DistEmbedding
      The list of DistEmbedding.
  lr : float
      The learning rate.
docstr: Return the state pertaining to current rank of the optimizer.
  
  Returns
  -------
  dict
      Local state dict
      Example Dict of Adagrad Optimizer:
      .. code-block:: json
  
      {
          "params": {
              "_lr": 0.01,
              "_eps": "1e-8",
              "world_size": 2
          },
          "emb_states": {
              "emb_name1": {
                  "ids": [0, 2, 4, 6 ,8 ,10], ## tensor,
                  "emb_name1_sum": [0.1 , 0.2, 0.5, 0.1, 0.2] ## tensor,
              },
              "emb_name2": {
                  "ids": [0, 2, 4, 6 ,8 ,10], ## tensor,
                  "emb_name2_sum": [0.3 , 0.2, 0.4, 0.5, 0.2] ## tensor,
              }
          }
      }
  
      :param json: json object
  
  See Also
  --------
  load_local_state_dict
docstr_tok: ["Return","the","state","pertaining","to","current","rank","of","the","optimizer",".","Returns","--","--","--","-","dict","Local","state","dict","Example","Dict","of","Adagrad","Optimizer",":","..","code-block",":",":","json","{","``","params","''",":","{","``","_lr","''",":","0.01",",","``","_eps","''",":","``","1e-8","''",",","``","world_size","''",":","2","}",",","``","emb_states","''",":","{","``","emb_name1","''",":","{","``","ids","''",":","[","0",",","2",",","4",",","6",",8",",10","]",",","#","#","tensor",",","``","emb_name1_sum","''",":","[","0.1",",","0.2",",","0.5",",","0.1",",","0.2","]","#","#","tensor",",","}",",","``","emb_name2","''",":","{","``","ids","''",":","[","0",",","2",",","4",",","6",",8",",10","]",",","#","#","tensor",",","``","emb_name2_sum","''",":","[","0.3",",","0.2",",","0.4",",","0.5",",","0.2","]","#","#","tensor",",","}","}","}",":","param","json",":","json","object","See","Also","--","--","--","--","load_local_state_dict"]
code: def local_state_dict(self):
      """Return the state pertaining to current rank of the optimizer.
  
      Returns
      -------
      dict
          Local state dict
          Example Dict of Adagrad Optimizer:
          .. code-block:: json
  
          {
              "params": {
                  "_lr": 0.01,
                  "_eps": "1e-8",
                  "world_size": 2
              },
              "emb_states": {
                  "emb_name1": {
                      "ids": [0, 2, 4, 6 ,8 ,10], ## tensor,
                      "emb_name1_sum": [0.1 , 0.2, 0.5, 0.1, 0.2] ## tensor,
                  },
                  "emb_name2": {
                      "ids": [0, 2, 4, 6 ,8 ,10], ## tensor,
                      "emb_name2_sum": [0.3 , 0.2, 0.4, 0.5, 0.2] ## tensor,
                  }
              }
          }
  
          :param json: json object
  
      See Also
      --------
      load_local_state_dict
      """
      local_state_dict = {}
      local_state_dict[EMB_STATES] = {}
      local_state_dict[PARAMS] = {WORLD_SIZE: self._world_size}
      for emb in self._params:
          trainers_per_machine = self._world_size // max(
              1, dgl.distributed.get_num_machines()
          )
          emb_state_dict = {}
          part_policy = (
              emb.part_policy
              if emb.part_policy
              else emb.weight.part_policy
          )
          idx = self._get_local_ids(part_policy)
          if trainers_per_machine > 1:
              kv_idx_split = (idx % trainers_per_machine).long()
              local_rank = self._rank % trainers_per_machine
              mask = kv_idx_split == local_rank
              idx = F.boolean_mask(idx, mask)
          emb_state_dict.update({IDS: idx})
          emb_state = {}
          states = (
              list(self._state[emb.name])
              if isinstance(self._state[emb.name], tuple)
              else [self._state[emb.name]]
          )
          emb_state = {state.name: state[idx] for state in states}
          emb_state_dict.update({STATES: emb_state})
          local_state_dict[EMB_STATES].update(
              {emb.name: emb_state_dict}
          )
      local_state_dict[PARAMS].update(self._defaults)
      return local_state_dict
  
imports: import abc
  import warnings
  from abc import abstractmethod
  from os.path import exists
  import torch
  import dgl
  from ....None import backend
  from ...dist_tensor import DistTensor
  from ...graph_partition_book import EDGE_PART_POLICY, NODE_PART_POLICY
  from ...nn.pytorch import DistEmbedding
  from .utils import alltoall, alltoallv
label_desc: Use image node_id 2 for calling the DistSparseGradOptimizer obj's underlying member method code with example usage: obj.local_state_dict() and returns: local_state_dict