class_docstr: Abstract class offering interface which should be implemented by all NeMo models.
class_docstr_tok: ["Abstract","class","offering","interface","which","should","be","implemented","by","all","NeMo","models","."]
docstr: Instantiates an instance of NeMo from NVIDIA NGC cloud
  Use restore_from() to instantiate from a local .nemo file.
  Args:
      model_name: string key which will be used to find the module.
      refresh_cache: If set to True, then when fetching from cloud, this will re-fetch the file
          from cloud even if it is already found in a cache locally.
      override_config_path: path to a yaml config that will override the internal
          config file
      map_location: Optional torch.device() to map the instantiated model to a device.
          By default (None), it will select a GPU if available, falling back to CPU otherwise.
      strict: Passed to torch.load_state_dict. By default true.
      return_config: If set to true, will return just the underlying config of the restored
          model as an OmegaConf DictConfig object without instantiating the model.
  
  Returns:
      A model instance of a particular model class or its underlying config (if return_config is set).
docstr_tok: ["Instantiates","an","instance","of","NeMo","from","NVIDIA","NGC","cloud","Use","restore_from","(",")","to","instantiate","from","a","local",".nemo","file",".","Args",":","model_name",":","string","key","which","will","be","used","to","find","the","module",".","refresh_cache",":","If","set","to","True",",","then","when","fetching","from","cloud",",","this","will","re-fetch","the","file","from","cloud","even","if","it","is","already","found","in","a","cache","locally",".","override_config_path",":","path","to","a","yaml","config","that","will","override","the","internal","config","file","map_location",":","Optional","torch.device","(",")","to","map","the","instantiated","model","to","a","device",".","By","default","(","None",")",",","it","will","select","a","GPU","if","available",",","falling","back","to","CPU","otherwise",".","strict",":","Passed","to","torch.load_state_dict",".","By","default","true",".","return_config",":","If","set","to","true",",","will","return","just","the","underlying","config","of","the","restored","model","as","an","OmegaConf","DictConfig","object","without","instantiating","the","model",".","Returns",":","A","model","instance","of","a","particular","model","class","or","its","underlying","config","(","if","return_config","is","set",")","."]
code: def from_pretrained(
      cls,
      model_name: str,
      refresh_cache: bool = False,
      override_config_path: Optional[str] = None,
      map_location: Optional["torch.device"] = None,
      strict: bool = True,
      return_config: bool = False,
      trainer: Optional["Trainer"] = None,
      save_restore_connector: SaveRestoreConnector = None,
  ):
      """
      Instantiates an instance of NeMo from NVIDIA NGC cloud
      Use restore_from() to instantiate from a local .nemo file.
      Args:
          model_name: string key which will be used to find the module.
          refresh_cache: If set to True, then when fetching from cloud, this will re-fetch the file
              from cloud even if it is already found in a cache locally.
          override_config_path: path to a yaml config that will override the internal
              config file
          map_location: Optional torch.device() to map the instantiated model to a device.
              By default (None), it will select a GPU if available, falling back to CPU otherwise.
          strict: Passed to torch.load_state_dict. By default true.
          return_config: If set to true, will return just the underlying config of the restored
              model as an OmegaConf DictConfig object without instantiating the model.
  
      Returns:
          A model instance of a particular model class or its underlying config (if return_config is set).
      """
      if save_restore_connector is None:
          save_restore_connector = SaveRestoreConnector()
  
      # Resolve if the pretrained model name is from NGC or other sources
      # HF Hub source
      if "/" in model_name:
          (
              class_,
              nemo_model_file_in_cache,
          ) = cls._get_hf_hub_pretrained_model_info(
              model_name=model_name, refresh_cache=refresh_cache
          )
      else:
          # NGC source
          (
              class_,
              nemo_model_file_in_cache,
          ) = cls._get_ngc_pretrained_model_info(
              model_name=model_name, refresh_cache=refresh_cache
          )
  
      instance = class_.restore_from(
          restore_path=nemo_model_file_in_cache,
          override_config_path=override_config_path,
          map_location=map_location,
          strict=strict,
          return_config=return_config,
          trainer=trainer,
          save_restore_connector=save_restore_connector,
      )
      return instance
  
imports: import hashlib
  import inspect
  import traceback
  from abc import ABC, abstractmethod
  from contextlib import contextmanager
  from dataclasses import dataclass, field
  from enum import Enum
  from functools import total_ordering
  from pathlib import Path
  from typing import Dict, Iterable, List, Optional, Tuple, Union
  import hydra
  import torch
  import wrapt
  from huggingface_hub import HfApi, HfFolder, ModelFilter, hf_hub_download
  from huggingface_hub.hf_api import ModelInfo
  from omegaconf import DictConfig, OmegaConf
  import nemo
  from nemo.core.connectors.save_restore_connector import SaveRestoreConnector
  from nemo.core.neural_types import NeuralType, NeuralTypeComparisonResult
  from nemo.utils import logging
  from nemo.utils.cloud import maybe_download_from_cloud
  from nemo.utils.data_utils import resolve_cache_dir
  from nemo.utils.model_utils import import_class_by_path, maybe_update_config_version
label_desc: Use image node_id 5 for calling the Model obj's underlying member method code with example usage: obj.from_pretrained(cls, model_name, refresh_cache, override_config_path, map_location, strict, return_config, trainer, save_restore_connector) and returns: instance