code: def from_config(cls, config, **kwargs):
      trust_remote_code = kwargs.pop("trust_remote_code", None)
      has_remote_code = (
          hasattr(config, "auto_map")
          and cls.__name__ in config.auto_map
      )
      has_local_code = type(config) in cls._model_mapping.keys()
      trust_remote_code = resolve_trust_remote_code(
          trust_remote_code,
          config._name_or_path,
          has_local_code,
          has_remote_code,
      )
  
      if has_remote_code and trust_remote_code:
          class_ref = config.auto_map[cls.__name__]
          if "--" in class_ref:
              repo_id, class_ref = class_ref.split("--")
          else:
              repo_id = config.name_or_path
          model_class = get_class_from_dynamic_module(
              class_ref, repo_id, **kwargs
          )
          if os.path.isdir(config._name_or_path):
              model_class.register_for_auto_class(cls.__name__)
          else:
              cls.register(config.__class__, model_class, exist_ok=True)
          _ = kwargs.pop("code_revision", None)
          return model_class._from_config(config, **kwargs)
      elif type(config) in cls._model_mapping.keys():
          model_class = _get_model_class(config, cls._model_mapping)
          return model_class._from_config(config, **kwargs)
  
      raise ValueError(
          f"Unrecognized configuration class {config.__class__} for this kind of AutoModel: {cls.__name__}.\n"
          f"Model type should be one of {', '.join(c.__name__ for c in cls._model_mapping.keys())}."
      )
  
imports: import copy
  import importlib
  import json
  import os
  import warnings
  from collections import OrderedDict
  from ...configuration_utils import PretrainedConfig
  from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code
  from ...utils import CONFIG_NAME, cached_file, copy_func, extract_commit_hash, find_adapter_config_file, is_peft_available, logging, requires_backends
  from .configuration_auto import AutoConfig, model_type_to_module_name, replace_list_option_in_docstrings
label_desc: Use image node_id 2 for calling the _BaseAutoModelClass obj's underlying member method code with example usage: obj.from_config(cls, config) and returns: model_class, model_class