code: def get_weight(name: str) -> WeightsEnum:
      """
      Gets the weights enum value by its full name. Example: "ResNet50_Weights.IMAGENET1K_V1"
  
      Args:
          name (str): The name of the weight enum entry.
  
      Returns:
          WeightsEnum: The requested weight enum.
      """
      try:
          enum_name, value_name = name.split(".")
      except ValueError:
          raise ValueError(f"Invalid weight name provided: '{name}'.")
  
      base_module_name = ".".join(
          sys.modules[__name__].__name__.split(".")[:-1]
      )
      base_module = importlib.import_module(base_module_name)
      model_modules = [base_module] + [
          x[1]
          for x in inspect.getmembers(base_module, inspect.ismodule)
          if x[1].__file__.endswith("__init__.py")  # type: ignore[union-attr]
      ]
  
      weights_enum = None
      for m in model_modules:
          potential_class = m.__dict__.get(enum_name, None)
          if potential_class is not None and issubclass(
              potential_class, WeightsEnum
          ):
              weights_enum = potential_class
              break
  
      if weights_enum is None:
          raise ValueError(
              f"The weight enum '{enum_name}' for the specific method couldn't be retrieved."
          )
  
      return weights_enum[value_name]
  
imports: import fnmatch
  import importlib
  import inspect
  import sys
  from dataclasses import dataclass
  from enum import Enum
  from functools import partial
  from inspect import signature
  from types import ModuleType
  from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Set, Type, TypeVar, Union
  from torch import nn
  from .._internally_replaced_utils import load_state_dict_from_url
label_desc: Use image node_id 1 for calling a global function with example usage: get_weight(name) and returns: weights_enum