class_docstr: Single piece of global state to keep track of the mapping between names and dimensions.
  
  Replaces the plate :class:`~pyro.poutine.runtime._DimAllocator`,
  the enum :class:`~pyro.poutine.runtime._EnumAllocator`, the ``stack`` in :class:`~MarkovMessenger`,
  ``_param_dims`` and ``_value_dims`` in :class:`~EnumMessenger`, and ``dim_to_symbol`` in ``msg['infer']``
class_docstr_tok: ["Single","piece","of","global","state","to","keep","track","of","the","mapping","between","names","and","dimensions",".","Replaces","the","plate",":","class",":","`","~pyro.poutine.runtime._DimAllocator","`",",","the","enum",":","class",":","`","~pyro.poutine.runtime._EnumAllocator","`",",","the","``","stack","``","in",":","class",":","`","~MarkovMessenger","`",",","``","_param_dims","``","and","``","_value_dims","``","in",":","class",":","`","~EnumMessenger","`",",","and","``","dim_to_symbol","``","in","``","msg","[","'infer","'","]","``"]
code: def set_first_available_dim(self, dim):
      assert dim is None or (self.MAX_DIM < dim < 0)
      old_dim, self._first_available_dim = (
          self._first_available_dim,
          dim,
      )
      return old_dim
  
imports: from collections import Counter, OrderedDict, namedtuple
  from enum import Enum
label_desc: Use image node_id 2 for calling the DimStack obj's underlying member method code with example usage: obj.set_first_available_dim(dim) and returns: old_dim