code: def from_jsonld(cls, data, __reference__=None, __source__=None):
          
          if isinstance(data, cls):
              return data
  
          if not isinstance(data, dict):
              raise ValueError(data)
  
          if '@type' in data:
              type_ = tuple(sorted(data['@type']))
              if type_ in cls.__type_registry__ and getattr(
                  cls, '_jsonld_type', None
              ) != type_:
                  new_cls = cls.__type_registry__[type_]
                  if cls != new_cls:
                      return new_cls.from_jsonld(data)
  
          if cls._jsonld_translate:
              data = ld.compact(data, {'@context': cls._jsonld_translate})
              data.pop('@context', None)
  
          data.setdefault('@context', cls._jsonld_context)
  
          if data['@context'] != cls._jsonld_context:
              compacted = ld.compact(data, {'@context': cls._jsonld_context})
          else:
              compacted = data
  
          # assert compacted['@type'] == cls._jsonld_type, '@type must be equal'
          # TODO update self(not cls)._jsonld_context with data['@context']
          fields = cls._jsonld_fields
  
          if __reference__:
              with with_reference(__reference__):
                  self = cls(
                      **{
                          k.lstrip('_'): v
                          for k, v in compacted.items() if k in fields
                      }
                  )
          else:
              self = cls(
                  **{
                      k.lstrip('_'): v
                      for k, v in compacted.items() if k in fields
                  }
              )
          if __source__:
              setattr(self, '__source__', __source__)
          return self
docs: Instantiate a JSON-LD class from data.