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: Should list all pre-trained models available via Hugging Face Hub.
  
  The following metadata can be passed via the `model_filter` for additional results.
  Metadata:
      resolve_card_info: Bool flag, if set, returns the model card metadata. Default: False.
      limit_results: Optional int, limits the number of results returned.
  
  .. code-block:: python
  
      # You can replace <DomainSubclass> with any subclass of ModelPT.
      from nemo.core import ModelPT
  
      # Get default ModelFilter
      filt = <DomainSubclass>.get_hf_model_filter()
  
      # Make any modifications to the filter as necessary
      filt.language = [...]
      filt.task = ...
      filt.tags = [...]
  
      # Add any metadata to the filter as needed
      filt.limit_results = 5
  
      # Obtain model info
      model_infos = <DomainSubclass>.search_huggingface_models(model_filter=filt)
  
      # Browse through cards and select an appropriate one
      card = model_infos[0]
  
      # Restore model using `modelId` of the card.
      model = ModelPT.from_pretrained(card.modelId)
  
  Args:
      model_filter: Optional ModelFilter or List[ModelFilter] (from Hugging Face Hub)
          that filters the returned list of compatible model cards, and selects all results from each filter.
          Users can then use `model_card.modelId` in `from_pretrained()` to restore a NeMo Model.
          If no ModelFilter is provided, uses the classes default filter as defined by `get_hf_model_filter()`.
  
  Returns:
      A list of ModelInfo entries.
docstr_tok: ["Should","list","all","pre-trained","models","available","via","Hugging","Face","Hub",".","The","following","metadata","can","be","passed","via","the","`","model_filter","`","for","additional","results",".","Metadata",":","resolve_card_info",":","Bool","flag",",","if","set",",","returns","the","model","card","metadata",".","Default",":","False",".","limit_results",":","Optional","int",",","limits","the","number","of","results","returned",".","..","code-block",":",":","python","#","You","can","replace","<","DomainSubclass",">","with","any","subclass","of","ModelPT",".","from","nemo.core","import","ModelPT","#","Get","default","ModelFilter","filt","=","<","DomainSubclass",">",".get_hf_model_filter","(",")","#","Make","any","modifications","to","the","filter","as","necessary","filt.language","=","[","...","]","filt.task","=","...","filt.tags","=","[","...","]","#","Add","any","metadata","to","the","filter","as","needed","filt.limit_results","=","5","#","Obtain","model","info","model_infos","=","<","DomainSubclass",">",".search_huggingface_models","(","model_filter=filt",")","#","Browse","through","cards","and","select","an","appropriate","one","card","=","model_infos","[","0","]","#","Restore","model","using","`","modelId","`","of","the","card",".","model","=","ModelPT.from_pretrained","(","card.modelId",")","Args",":","model_filter",":","Optional","ModelFilter","or","List","[","ModelFilter","]","(","from","Hugging","Face","Hub",")","that","filters","the","returned","list","of","compatible","model","cards",",","and","selects","all","results","from","each","filter",".","Users","can","then","use","`","model_card.modelId","`","in","`","from_pretrained","(",")","`","to","restore","a","NeMo","Model",".","If","no","ModelFilter","is","provided",",","uses","the","classes","default","filter","as","defined","by","`","get_hf_model_filter","(",")","`",".","Returns",":","A","list","of","ModelInfo","entries","."]
code: def search_huggingface_models(
      cls,
      model_filter: Optional[
          Union[ModelFilter, List[ModelFilter]]
      ] = None,
  ) -> List[ModelInfo]:
      """
      Should list all pre-trained models available via Hugging Face Hub.
  
      The following metadata can be passed via the `model_filter` for additional results.
      Metadata:
          resolve_card_info: Bool flag, if set, returns the model card metadata. Default: False.
          limit_results: Optional int, limits the number of results returned.
  
      .. code-block:: python
  
          # You can replace <DomainSubclass> with any subclass of ModelPT.
          from nemo.core import ModelPT
  
          # Get default ModelFilter
          filt = <DomainSubclass>.get_hf_model_filter()
  
          # Make any modifications to the filter as necessary
          filt.language = [...]
          filt.task = ...
          filt.tags = [...]
  
          # Add any metadata to the filter as needed
          filt.limit_results = 5
  
          # Obtain model info
          model_infos = <DomainSubclass>.search_huggingface_models(model_filter=filt)
  
          # Browse through cards and select an appropriate one
          card = model_infos[0]
  
          # Restore model using `modelId` of the card.
          model = ModelPT.from_pretrained(card.modelId)
  
      Args:
          model_filter: Optional ModelFilter or List[ModelFilter] (from Hugging Face Hub)
              that filters the returned list of compatible model cards, and selects all results from each filter.
              Users can then use `model_card.modelId` in `from_pretrained()` to restore a NeMo Model.
              If no ModelFilter is provided, uses the classes default filter as defined by `get_hf_model_filter()`.
  
      Returns:
          A list of ModelInfo entries.
      """
      # Resolve model filter if not provided as argument
      if model_filter is None:
          model_filter = cls.get_hf_model_filter()
  
      # If single model filter, wrap into list
      if not isinstance(model_filter, Iterable):
          model_filter = [model_filter]
  
      # Inject `nemo` library filter
      for mfilter in model_filter:
          if (
              isinstance(mfilter.library, str)
              and mfilter.library != "nemo"
          ):
              logging.warning(
                  f"Model filter's `library` tag updated be `nemo`. Original value: {mfilter.library}"
              )
              mfilter.library = "nemo"
  
          elif (
              isinstance(mfilter, Iterable)
              and "nemo" not in mfilter.library
          ):
              logging.warning(
                  f"Model filter's `library` list updated to include `nemo`. Original value: {mfilter.library}"
              )
              mfilter.library = list(mfilter)
              mfilter.library.append("nemo")
  
      # Check if api token exists, use if it does
      is_token_available = HfFolder.get_token() is not None
  
      # Search for all valid models after filtering
      api = HfApi()
  
      # Setup extra arguments for model filtering
      all_results = []  # type: List[ModelInfo]
  
      for mfilter in model_filter:
          cardData = None
          limit = None
  
          if (
              hasattr(mfilter, "resolve_card_info")
              and mfilter.resolve_card_info is True
          ):
              cardData = True
  
          if (
              hasattr(mfilter, "limit_results")
              and mfilter.limit_results is not None
          ):
              limit = mfilter.limit_results
  
          results = api.list_models(
              filter=mfilter,
              use_auth_token=is_token_available,
              sort="lastModified",
              direction=-1,
              cardData=cardData,
              limit=limit,
          )  # type: List[ModelInfo]
  
          all_results.extend(results)
  
      return all_results
  
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 2 for calling the Model obj's underlying member method code with example usage: obj.search_huggingface_models(cls, model_filter) and returns: all_results