class_docstr: Dictionary Data Type
class_docstr_tok: ["Dictionary","Data","Type"]
docstr: Constructs a Dictionary, given its key type
  
  Parameters
  ----------
  key_type: Int64 | String
  
  Examples
  --------
  >>> from coremltools.models.datatypes import Dictionary, Int64, String
  
  # Create a dictionary with string keys
  >>> str_key_dict = Dictionary(key_type=String)
  
  # Create a dictionary with int keys
  >>> int_key_dict = Dictionary(Int64)
docstr_tok: ["Constructs","a","Dictionary",",","given","its","key","type","Parameters","--","--","--","--","--","key_type",":","Int64","|","String","Examples","--","--","--","--",">",">",">","from","coremltools.models.datatypes","import","Dictionary",",","Int64",",","String","#","Create","a","dictionary","with","string","keys",">",">",">","str_key_dict","=","Dictionary","(","key_type=String",")","#","Create","a","dictionary","with","int","keys",">",">",">","int_key_dict","=","Dictionary","(","Int64",")"]
code: def __init__(self, key_type=None):
      """
      Constructs a Dictionary, given its key type
  
      Parameters
      ----------
      key_type: Int64 | String
  
      Examples
      --------
      >>> from coremltools.models.datatypes import Dictionary, Int64, String
  
      # Create a dictionary with string keys
      >>> str_key_dict = Dictionary(key_type=String)
  
      # Create a dictionary with int keys
      >>> int_key_dict = Dictionary(Int64)
      """
      # Resolve it to a class if it's
      global _simple_type_remap
      if key_type in _simple_type_remap:
          key_type = _simple_type_remap[key_type]
  
      if not isinstance(key_type, (Int64, String)):
          raise TypeError(
              "Key type for dictionary must be either string or integer."
          )
  
      self.key_type = key_type
  
      _DatatypeBase.__init__(
          self,
          "Dictionary",
          "Dictionary(%s)" % repr(self.key_type),
          None,
      )
  
imports: import numpy
  from ..proto import Model_pb2
label_desc: Use image node_id 1 to create a new Dictionary object from inherited base classes: _DatatypeBase with example: obj = Dictionary(key_type)