code: def infer_ast_from_something(self, obj, context=None):
          
          if hasattr(obj, "__class__") and not isinstance(obj, type):
              klass = obj.__class__
          else:
              klass = obj
          try:
              modname = klass.__module__
          except AttributeError as exc:
              raise exceptions.AstroidBuildingError(
                  "Unable to get module for {class_repr}.",
                  cls=klass,
                  class_repr=safe_repr(klass),
              ) from exc
          except Exception as exc:
              raise exceptions.AstroidImportError(
                  "Unexpected error while retrieving module for {class_repr}:\n"
                  "{error}",
                  cls=klass,
                  class_repr=safe_repr(klass),
              ) from exc
          try:
              name = klass.__name__
          except AttributeError as exc:
              raise exceptions.AstroidBuildingError(
                  "Unable to get name for {class_repr}:\n",
                  cls=klass,
                  class_repr=safe_repr(klass),
              ) from exc
          except Exception as exc:
              raise exceptions.AstroidImportError(
                  "Unexpected error while retrieving name for {class_repr}:\n" "{error}",
                  cls=klass,
                  class_repr=safe_repr(klass),
              ) from exc
          # take care, on living object __module__ is regularly wrong :(
          modastroid = self.ast_from_module_name(modname)
          if klass is obj:
              for inferred in modastroid.igetattr(name, context):
                  yield inferred
          else:
              for inferred in modastroid.igetattr(name, context):
                  yield inferred.instantiate_class()
docs: infer astroid for the given class