code: def _from_dict(cls, mapping):
          
          if mapping.get("all"):
              return cls(all_=True)
  
          r_mappings = mapping.get("ranges", ())
          ranges = [KeyRange(**r_mapping) for r_mapping in r_mappings]
  
          return cls(keys=mapping.get("keys", ()), ranges=ranges)
docs: Create an instance from the corresponding state mapping.
  
          :type mapping: dict
          :param mapping: the instance state.