We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] loading segmentation torch models errror, has no attribute 'load_state_dict_from_url'
### System information

-   **OS Platform and Distribution**: `Ubuntu 20.04`
-   **FiftyOne installed from (pip or source)**: `pip`, from within `conda` environment
-   **FiftyOne version (run `fiftyone --version`)**: `FiftyOne v0.16.0, Voxel51, Inc.`
-   **Python version**: `Python 3.9.7`
-   **Torch version**: `1.11.0`
-   **Torchvision version**: `0.12.0`

### Code to reproduce

```
import fiftyone.zoo as foz
model = foz.load_zoo_model("deeplabv3-resnet101-coco-torch")
```

### Describe the problem
The model fails to load (was taken from the [semantic segmentation evaluation doc](https://voxel51.com/docs/fiftyone/user_guide/evaluation.html#semantic-segmentations). Ultimately the error is  `AttributeError: module 'torchvision.models.segmentation.deeplabv3' has no attribute 'load_state_dict_from_url'`. This applies to all the PyTorch segmentation models listed [here](https://voxel51.com/docs/fiftyone/user_guide/model_zoo/models.html).

### Other info / logs
```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [2], in <cell line: 3>()
      1 import fiftyone.zoo as foz
----> 3 model = foz.load_zoo_model("deeplabv3-resnet101-coco-torch")

File ~/miniconda3/lib/python3.9/site-packages/fiftyone/zoo/models/__init__.py:207, in load_zoo_model(name, download_if_necessary, install_requirements, error_level, **kwargs)
    204 config_dict = deepcopy(model.default_deployment_config_dict)
    205 model_path = model.get_path_in_dir(models_dir)
--> 207 return fom.load_model(config_dict, model_path=model_path, **kwargs)

File ~/miniconda3/lib/python3.9/site-packages/fiftyone/core/models.py:1505, in load_model(model_config_dict, model_path, **kwargs)
   1499         raise ValueError(
   1500             "Model config must implement the %s interface"
   1501             % etal.HasPublishedModel
   1502         )
   1504 # Build model
-> 1505 return config.build()

File ~/miniconda3/lib/python3.9/site-packages/eta/core/learning.py:296, in ModelConfig.build(self)
    289 def build(self):
    290     """Factory method that builds the Model instance from the config
    291     specified by this class.
    292 
    293     Returns:
    294         a Model instance
    295     """
--> 296     return self._model_cls(self.config)

File ~/miniconda3/lib/python3.9/site-packages/fiftyone/utils/torch.py:230, in TorchImageModel.__init__(self, config)
    226 self._device = torch.device("cuda:0" if self._using_gpu else "cpu")
    227 self._using_half_precision = (
    228     self.config.use_half_precision is True
    229 ) and self._using_gpu
--> 230 self._model = self._load_model(config)
    231 self._no_grad = None
    232 self._benchmark_orig = None

File ~/miniconda3/lib/python3.9/site-packages/fiftyone/utils/torch.py:471, in TorchImageModel._load_model(self, config)
    468 def _load_model(self, config):
    469     self._download_model(config)
--> 471     model = self._load_network(config)
    473     model = model.to(self._device)
    474     if self._using_half_precision:

File ~/miniconda3/lib/python3.9/site-packages/fiftyone/zoo/models/torch.py:97, in TorchvisionImageModel._load_network(self, config)
     94 kwargs = config.entrypoint_args or {}
     95 model_dir = fo.config.model_zoo_dir
---> 97 monkey_patcher = _make_load_state_dict_from_url_monkey_patcher(
     98     entrypoint, model_dir
     99 )
    100 with monkey_patcher:
    101     # Builds net and loads state dict from `model_dir`
    102     model = entrypoint(**kwargs)

File ~/miniconda3/lib/python3.9/site-packages/fiftyone/zoo/models/torch.py:114, in _make_load_state_dict_from_url_monkey_patcher(entrypoint, model_dir)
    108 """Monkey patches all instances of ``load_state_dict_from_url()`` that are
    109 reachable from the given ``entrypoint`` function in the
    110 :mod:`torchvision:torchvision.models` namespace so that models will be
    111 loaded from ``model_dir`` and not from the Torch Hub cache directory.
    112 """
    113 entrypoint_module = inspect.getmodule(entrypoint)
--> 114 load_state_dict_from_url = entrypoint_module.load_state_dict_from_url
    116 def custom_load_state_dict_from_url(url, **kwargs):
    117     return load_state_dict_from_url(url, model_dir=model_dir, **kwargs)

AttributeError: module 'torchvision.models.segmentation.deeplabv3' has no attribute 'load_state_dict_from_url'
```

### What areas of FiftyOne does this bug affect?

-   [ ] `App`: FiftyOne application issue
-   [x] `Core`: Core `fiftyone` Python library issue
-   [ ] `Server`: Fiftyone server issue

### Willingness to contribute

The FiftyOne Community encourages bug fix contributions. Would you or another
member of your organization be willing to contribute a fix for this bug to the
FiftyOne codebase?

-   [ ] Yes. I can contribute a fix for this bug independently.
-   [x] Yes. I would be willing to contribute a fix for this bug with guidance
        from the FiftyOne community.
-   [ ] No. I cannot contribute a bug fix at this time.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `fiftyone/zoo/models/torch.py`
Content:
```
1 """
2 FiftyOne Zoo models provided by :mod:`torchvision:torchvision.models`.
3 
4 | Copyright 2017-2022, Voxel51, Inc.
5 | `voxel51.com <https://voxel51.com/>`_
6 |
7 """
8 import inspect
9 
10 import eta.core.utils as etau
11 
12 import fiftyone as fo
13 import fiftyone.core.utils as fou
14 import fiftyone.utils.torch as fout
15 import fiftyone.zoo.models as fozm
16 
17 fou.ensure_torch()
18 import torchvision
19 
20 
21 class TorchvisionImageModelConfig(
22     fout.TorchImageModelConfig, fozm.HasZooModel
23 ):
24     """Configuration for running a :class:`TorchvisionImageModel`.
25 
26     Args:
27         entrypoint_fcn: a fully-qualified function string like
28             ``"torchvision.models.inception_v3"`` specifying the entrypoint
29             function that loads the model
30         entrypoint_args (None): a dictionary of arguments for
31             ``entrypoint_fcn``
32         output_processor_cls: a string like
33             ``"fifytone.utils.torch.ClassifierOutputProcessor"`` specifying the
34             :class:`fifytone.utils.torch.OutputProcessor` to use
35         output_processor_args (None): a dictionary of arguments for
36             ``output_processor_cls(classes=classes, **kwargs)``
37         confidence_thresh (None): an optional confidence threshold apply to any
38             applicable predictions generated by the model
39         labels_string (None): a comma-separated list of the class names for the
40             model, if applicable
41         labels_path (None): the path to the labels map for the model, if
42             applicable
43         mask_targets (None): a mask targets dict for the model, if applicable
44         mask_targets_path (None): the path to a mask targets map for the model,
45             if applicable
46         skeleton (None): a keypoint skeleton dict for the model, if applicable
47         image_min_size (None): resize the input images during preprocessing, if
48             necessary, so that the image dimensions are at least this
49             ``(width, height)``
50         image_min_dim (None): resize input images during preprocessing, if
51             necessary, so that the smaller image dimension is at least this
52             value
53         image_max_size (None): resize the input images during preprocessing, if
54             necessary, so that the image dimensions are at most this
55             ``(width, height)``
56         image_max_dim (None): resize input images during preprocessing, if
57             necessary, so that the largest image dimension is at most this
58             value.
59         image_size (None): a ``(width, height)`` to which to resize the input
60             images during preprocessing
61         image_dim (None): resize the smaller input dimension to this value
62             during preprocessing
63         image_mean (None): a 3-array of mean values in ``[0, 1]`` for
64             preprocessing the input images
65         image_std (None): a 3-array of std values in ``[0, 1]`` for
66             preprocessing the input images
67             inputs that are lists of Tensors
68         embeddings_layer (None): the name of a layer whose output to expose as
69             embeddings. Prepend ``"<"`` to save the input tensor instead
70         use_half_precision (None): whether to use half precision (only
71             supported when using GPU)
72         cudnn_benchmark (None): a value to use for
73             :attr:`torch:torch.backends.cudnn.benchmark` while the model is
74             running
75     """
76 
77     def __init__(self, d):
78         d = self.init(d)
79         super().__init__(d)
80 
81 
82 class TorchvisionImageModel(fout.TorchImageModel):
83     """Wrapper for evaluating a :mod:`torchvision:torchvision.models` model on images.
84 
85     Args:
86         config: an :class:`TorchvisionImageModelConfig`
87     """
88 
89     def _download_model(self, config):
90         config.download_model_if_necessary()
91 
92     def _load_network(self, config):
93         entrypoint = etau.get_function(config.entrypoint_fcn)
94         kwargs = config.entrypoint_args or {}
95         model_dir = fo.config.model_zoo_dir
96 
97         monkey_patcher = _make_load_state_dict_from_url_monkey_patcher(
98             entrypoint, model_dir
99         )
100         with monkey_patcher:
101             # Builds net and loads state dict from `model_dir`
102             model = entrypoint(**kwargs)
103 
104         return model
105 
106 
107 def _make_load_state_dict_from_url_monkey_patcher(entrypoint, model_dir):
108     """Monkey patches all instances of ``load_state_dict_from_url()`` that are
109     reachable from the given ``entrypoint`` function in the
110     :mod:`torchvision:torchvision.models` namespace so that models will be
111     loaded from ``model_dir`` and not from the Torch Hub cache directory.
112     """
113     entrypoint_module = inspect.getmodule(entrypoint)
114     load_state_dict_from_url = entrypoint_module.load_state_dict_from_url
115 
116     def custom_load_state_dict_from_url(url, **kwargs):
117         return load_state_dict_from_url(url, model_dir=model_dir, **kwargs)
118 
119     return fou.MonkeyPatchFunction(
120         entrypoint_module,
121         custom_load_state_dict_from_url,
122         fcn_name=load_state_dict_from_url.__name__,
123         namespace=torchvision.models,
124     )
125
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/fiftyone/zoo/models/torch.py b/fiftyone/zoo/models/torch.py
--- a/fiftyone/zoo/models/torch.py
+++ b/fiftyone/zoo/models/torch.py
@@ -6,6 +6,7 @@
 |
 """
 import inspect
+from packaging import version
 
 import eta.core.utils as etau
 
@@ -111,6 +112,8 @@
     loaded from ``model_dir`` and not from the Torch Hub cache directory.
     """
     entrypoint_module = inspect.getmodule(entrypoint)
+    if version.parse(torchvision.__version__) >= version.parse("0.12.0"):
+        entrypoint_module = torchvision._internally_replaced_utils
     load_state_dict_from_url = entrypoint_module.load_state_dict_from_url
 
     def custom_load_state_dict_from_url(url, **kwargs):

{"golden_diff": "diff --git a/fiftyone/zoo/models/torch.py b/fiftyone/zoo/models/torch.py\n--- a/fiftyone/zoo/models/torch.py\n+++ b/fiftyone/zoo/models/torch.py\n@@ -6,6 +6,7 @@\n |\n \"\"\"\n import inspect\n+from packaging import version\n \n import eta.core.utils as etau\n \n@@ -111,6 +112,8 @@\n     loaded from ``model_dir`` and not from the Torch Hub cache directory.\n     \"\"\"\n     entrypoint_module = inspect.getmodule(entrypoint)\n+    if version.parse(torchvision.__version__) >= version.parse(\"0.12.0\"):\n+        entrypoint_module = torchvision._internally_replaced_utils\n     load_state_dict_from_url = entrypoint_module.load_state_dict_from_url\n \n     def custom_load_state_dict_from_url(url, **kwargs):\n", "issue": "[BUG] loading segmentation torch models errror, has no attribute 'load_state_dict_from_url'\n### System information\r\n\r\n-   **OS Platform and Distribution**: `Ubuntu 20.04`\r\n-   **FiftyOne installed from (pip or source)**: `pip`, from within `conda` environment\r\n-   **FiftyOne version (run `fiftyone --version`)**: `FiftyOne v0.16.0, Voxel51, Inc.`\r\n-   **Python version**: `Python 3.9.7`\r\n-   **Torch version**: `1.11.0`\r\n-   **Torchvision version**: `0.12.0`\r\n\r\n### Code to reproduce\r\n\r\n```\r\nimport fiftyone.zoo as foz\r\nmodel = foz.load_zoo_model(\"deeplabv3-resnet101-coco-torch\")\r\n```\r\n\r\n### Describe the problem\r\nThe model fails to load (was taken from the [semantic segmentation evaluation doc](https://voxel51.com/docs/fiftyone/user_guide/evaluation.html#semantic-segmentations). Ultimately the error is  `AttributeError: module 'torchvision.models.segmentation.deeplabv3' has no attribute 'load_state_dict_from_url'`. This applies to all the PyTorch segmentation models listed [here](https://voxel51.com/docs/fiftyone/user_guide/model_zoo/models.html).\r\n\r\n### Other info / logs\r\n```\r\n---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\nInput In [2], in <cell line: 3>()\r\n      1 import fiftyone.zoo as foz\r\n----> 3 model = foz.load_zoo_model(\"deeplabv3-resnet101-coco-torch\")\r\n\r\nFile ~/miniconda3/lib/python3.9/site-packages/fiftyone/zoo/models/__init__.py:207, in load_zoo_model(name, download_if_necessary, install_requirements, error_level, **kwargs)\r\n    204 config_dict = deepcopy(model.default_deployment_config_dict)\r\n    205 model_path = model.get_path_in_dir(models_dir)\r\n--> 207 return fom.load_model(config_dict, model_path=model_path, **kwargs)\r\n\r\nFile ~/miniconda3/lib/python3.9/site-packages/fiftyone/core/models.py:1505, in load_model(model_config_dict, model_path, **kwargs)\r\n   1499         raise ValueError(\r\n   1500             \"Model config must implement the %s interface\"\r\n   1501             % etal.HasPublishedModel\r\n   1502         )\r\n   1504 # Build model\r\n-> 1505 return config.build()\r\n\r\nFile ~/miniconda3/lib/python3.9/site-packages/eta/core/learning.py:296, in ModelConfig.build(self)\r\n    289 def build(self):\r\n    290     \"\"\"Factory method that builds the Model instance from the config\r\n    291     specified by this class.\r\n    292 \r\n    293     Returns:\r\n    294         a Model instance\r\n    295     \"\"\"\r\n--> 296     return self._model_cls(self.config)\r\n\r\nFile ~/miniconda3/lib/python3.9/site-packages/fiftyone/utils/torch.py:230, in TorchImageModel.__init__(self, config)\r\n    226 self._device = torch.device(\"cuda:0\" if self._using_gpu else \"cpu\")\r\n    227 self._using_half_precision = (\r\n    228     self.config.use_half_precision is True\r\n    229 ) and self._using_gpu\r\n--> 230 self._model = self._load_model(config)\r\n    231 self._no_grad = None\r\n    232 self._benchmark_orig = None\r\n\r\nFile ~/miniconda3/lib/python3.9/site-packages/fiftyone/utils/torch.py:471, in TorchImageModel._load_model(self, config)\r\n    468 def _load_model(self, config):\r\n    469     self._download_model(config)\r\n--> 471     model = self._load_network(config)\r\n    473     model = model.to(self._device)\r\n    474     if self._using_half_precision:\r\n\r\nFile ~/miniconda3/lib/python3.9/site-packages/fiftyone/zoo/models/torch.py:97, in TorchvisionImageModel._load_network(self, config)\r\n     94 kwargs = config.entrypoint_args or {}\r\n     95 model_dir = fo.config.model_zoo_dir\r\n---> 97 monkey_patcher = _make_load_state_dict_from_url_monkey_patcher(\r\n     98     entrypoint, model_dir\r\n     99 )\r\n    100 with monkey_patcher:\r\n    101     # Builds net and loads state dict from `model_dir`\r\n    102     model = entrypoint(**kwargs)\r\n\r\nFile ~/miniconda3/lib/python3.9/site-packages/fiftyone/zoo/models/torch.py:114, in _make_load_state_dict_from_url_monkey_patcher(entrypoint, model_dir)\r\n    108 \"\"\"Monkey patches all instances of ``load_state_dict_from_url()`` that are\r\n    109 reachable from the given ``entrypoint`` function in the\r\n    110 :mod:`torchvision:torchvision.models` namespace so that models will be\r\n    111 loaded from ``model_dir`` and not from the Torch Hub cache directory.\r\n    112 \"\"\"\r\n    113 entrypoint_module = inspect.getmodule(entrypoint)\r\n--> 114 load_state_dict_from_url = entrypoint_module.load_state_dict_from_url\r\n    116 def custom_load_state_dict_from_url(url, **kwargs):\r\n    117     return load_state_dict_from_url(url, model_dir=model_dir, **kwargs)\r\n\r\nAttributeError: module 'torchvision.models.segmentation.deeplabv3' has no attribute 'load_state_dict_from_url'\r\n```\r\n\r\n### What areas of FiftyOne does this bug affect?\r\n\r\n-   [ ] `App`: FiftyOne application issue\r\n-   [x] `Core`: Core `fiftyone` Python library issue\r\n-   [ ] `Server`: Fiftyone server issue\r\n\r\n### Willingness to contribute\r\n\r\nThe FiftyOne Community encourages bug fix contributions. Would you or another\r\nmember of your organization be willing to contribute a fix for this bug to the\r\nFiftyOne codebase?\r\n\r\n-   [ ] Yes. I can contribute a fix for this bug independently.\r\n-   [x] Yes. I would be willing to contribute a fix for this bug with guidance\r\n        from the FiftyOne community.\r\n-   [ ] No. I cannot contribute a bug fix at this time.\r\n\n", "before_files": [{"content": "\"\"\"\nFiftyOne Zoo models provided by :mod:`torchvision:torchvision.models`.\n\n| Copyright 2017-2022, Voxel51, Inc.\n| `voxel51.com <https://voxel51.com/>`_\n|\n\"\"\"\nimport inspect\n\nimport eta.core.utils as etau\n\nimport fiftyone as fo\nimport fiftyone.core.utils as fou\nimport fiftyone.utils.torch as fout\nimport fiftyone.zoo.models as fozm\n\nfou.ensure_torch()\nimport torchvision\n\n\nclass TorchvisionImageModelConfig(\n    fout.TorchImageModelConfig, fozm.HasZooModel\n):\n    \"\"\"Configuration for running a :class:`TorchvisionImageModel`.\n\n    Args:\n        entrypoint_fcn: a fully-qualified function string like\n            ``\"torchvision.models.inception_v3\"`` specifying the entrypoint\n            function that loads the model\n        entrypoint_args (None): a dictionary of arguments for\n            ``entrypoint_fcn``\n        output_processor_cls: a string like\n            ``\"fifytone.utils.torch.ClassifierOutputProcessor\"`` specifying the\n            :class:`fifytone.utils.torch.OutputProcessor` to use\n        output_processor_args (None): a dictionary of arguments for\n            ``output_processor_cls(classes=classes, **kwargs)``\n        confidence_thresh (None): an optional confidence threshold apply to any\n            applicable predictions generated by the model\n        labels_string (None): a comma-separated list of the class names for the\n            model, if applicable\n        labels_path (None): the path to the labels map for the model, if\n            applicable\n        mask_targets (None): a mask targets dict for the model, if applicable\n        mask_targets_path (None): the path to a mask targets map for the model,\n            if applicable\n        skeleton (None): a keypoint skeleton dict for the model, if applicable\n        image_min_size (None): resize the input images during preprocessing, if\n            necessary, so that the image dimensions are at least this\n            ``(width, height)``\n        image_min_dim (None): resize input images during preprocessing, if\n            necessary, so that the smaller image dimension is at least this\n            value\n        image_max_size (None): resize the input images during preprocessing, if\n            necessary, so that the image dimensions are at most this\n            ``(width, height)``\n        image_max_dim (None): resize input images during preprocessing, if\n            necessary, so that the largest image dimension is at most this\n            value.\n        image_size (None): a ``(width, height)`` to which to resize the input\n            images during preprocessing\n        image_dim (None): resize the smaller input dimension to this value\n            during preprocessing\n        image_mean (None): a 3-array of mean values in ``[0, 1]`` for\n            preprocessing the input images\n        image_std (None): a 3-array of std values in ``[0, 1]`` for\n            preprocessing the input images\n            inputs that are lists of Tensors\n        embeddings_layer (None): the name of a layer whose output to expose as\n            embeddings. Prepend ``\"<\"`` to save the input tensor instead\n        use_half_precision (None): whether to use half precision (only\n            supported when using GPU)\n        cudnn_benchmark (None): a value to use for\n            :attr:`torch:torch.backends.cudnn.benchmark` while the model is\n            running\n    \"\"\"\n\n    def __init__(self, d):\n        d = self.init(d)\n        super().__init__(d)\n\n\nclass TorchvisionImageModel(fout.TorchImageModel):\n    \"\"\"Wrapper for evaluating a :mod:`torchvision:torchvision.models` model on images.\n\n    Args:\n        config: an :class:`TorchvisionImageModelConfig`\n    \"\"\"\n\n    def _download_model(self, config):\n        config.download_model_if_necessary()\n\n    def _load_network(self, config):\n        entrypoint = etau.get_function(config.entrypoint_fcn)\n        kwargs = config.entrypoint_args or {}\n        model_dir = fo.config.model_zoo_dir\n\n        monkey_patcher = _make_load_state_dict_from_url_monkey_patcher(\n            entrypoint, model_dir\n        )\n        with monkey_patcher:\n            # Builds net and loads state dict from `model_dir`\n            model = entrypoint(**kwargs)\n\n        return model\n\n\ndef _make_load_state_dict_from_url_monkey_patcher(entrypoint, model_dir):\n    \"\"\"Monkey patches all instances of ``load_state_dict_from_url()`` that are\n    reachable from the given ``entrypoint`` function in the\n    :mod:`torchvision:torchvision.models` namespace so that models will be\n    loaded from ``model_dir`` and not from the Torch Hub cache directory.\n    \"\"\"\n    entrypoint_module = inspect.getmodule(entrypoint)\n    load_state_dict_from_url = entrypoint_module.load_state_dict_from_url\n\n    def custom_load_state_dict_from_url(url, **kwargs):\n        return load_state_dict_from_url(url, model_dir=model_dir, **kwargs)\n\n    return fou.MonkeyPatchFunction(\n        entrypoint_module,\n        custom_load_state_dict_from_url,\n        fcn_name=load_state_dict_from_url.__name__,\n        namespace=torchvision.models,\n    )\n", "path": "fiftyone/zoo/models/torch.py"}], "after_files": [{"content": "\"\"\"\nFiftyOne Zoo models provided by :mod:`torchvision:torchvision.models`.\n\n| Copyright 2017-2022, Voxel51, Inc.\n| `voxel51.com <https://voxel51.com/>`_\n|\n\"\"\"\nimport inspect\nfrom packaging import version\n\nimport eta.core.utils as etau\n\nimport fiftyone as fo\nimport fiftyone.core.utils as fou\nimport fiftyone.utils.torch as fout\nimport fiftyone.zoo.models as fozm\n\nfou.ensure_torch()\nimport torchvision\n\n\nclass TorchvisionImageModelConfig(\n    fout.TorchImageModelConfig, fozm.HasZooModel\n):\n    \"\"\"Configuration for running a :class:`TorchvisionImageModel`.\n\n    Args:\n        entrypoint_fcn: a fully-qualified function string like\n            ``\"torchvision.models.inception_v3\"`` specifying the entrypoint\n            function that loads the model\n        entrypoint_args (None): a dictionary of arguments for\n            ``entrypoint_fcn``\n        output_processor_cls: a string like\n            ``\"fifytone.utils.torch.ClassifierOutputProcessor\"`` specifying the\n            :class:`fifytone.utils.torch.OutputProcessor` to use\n        output_processor_args (None): a dictionary of arguments for\n            ``output_processor_cls(classes=classes, **kwargs)``\n        confidence_thresh (None): an optional confidence threshold apply to any\n            applicable predictions generated by the model\n        labels_string (None): a comma-separated list of the class names for the\n            model, if applicable\n        labels_path (None): the path to the labels map for the model, if\n            applicable\n        mask_targets (None): a mask targets dict for the model, if applicable\n        mask_targets_path (None): the path to a mask targets map for the model,\n            if applicable\n        skeleton (None): a keypoint skeleton dict for the model, if applicable\n        image_min_size (None): resize the input images during preprocessing, if\n            necessary, so that the image dimensions are at least this\n            ``(width, height)``\n        image_min_dim (None): resize input images during preprocessing, if\n            necessary, so that the smaller image dimension is at least this\n            value\n        image_max_size (None): resize the input images during preprocessing, if\n            necessary, so that the image dimensions are at most this\n            ``(width, height)``\n        image_max_dim (None): resize input images during preprocessing, if\n            necessary, so that the largest image dimension is at most this\n            value.\n        image_size (None): a ``(width, height)`` to which to resize the input\n            images during preprocessing\n        image_dim (None): resize the smaller input dimension to this value\n            during preprocessing\n        image_mean (None): a 3-array of mean values in ``[0, 1]`` for\n            preprocessing the input images\n        image_std (None): a 3-array of std values in ``[0, 1]`` for\n            preprocessing the input images\n            inputs that are lists of Tensors\n        embeddings_layer (None): the name of a layer whose output to expose as\n            embeddings. Prepend ``\"<\"`` to save the input tensor instead\n        use_half_precision (None): whether to use half precision (only\n            supported when using GPU)\n        cudnn_benchmark (None): a value to use for\n            :attr:`torch:torch.backends.cudnn.benchmark` while the model is\n            running\n    \"\"\"\n\n    def __init__(self, d):\n        d = self.init(d)\n        super().__init__(d)\n\n\nclass TorchvisionImageModel(fout.TorchImageModel):\n    \"\"\"Wrapper for evaluating a :mod:`torchvision:torchvision.models` model on images.\n\n    Args:\n        config: an :class:`TorchvisionImageModelConfig`\n    \"\"\"\n\n    def _download_model(self, config):\n        config.download_model_if_necessary()\n\n    def _load_network(self, config):\n        entrypoint = etau.get_function(config.entrypoint_fcn)\n        kwargs = config.entrypoint_args or {}\n        model_dir = fo.config.model_zoo_dir\n\n        monkey_patcher = _make_load_state_dict_from_url_monkey_patcher(\n            entrypoint, model_dir\n        )\n        with monkey_patcher:\n            # Builds net and loads state dict from `model_dir`\n            model = entrypoint(**kwargs)\n\n        return model\n\n\ndef _make_load_state_dict_from_url_monkey_patcher(entrypoint, model_dir):\n    \"\"\"Monkey patches all instances of ``load_state_dict_from_url()`` that are\n    reachable from the given ``entrypoint`` function in the\n    :mod:`torchvision:torchvision.models` namespace so that models will be\n    loaded from ``model_dir`` and not from the Torch Hub cache directory.\n    \"\"\"\n    entrypoint_module = inspect.getmodule(entrypoint)\n    if version.parse(torchvision.__version__) >= version.parse(\"0.12.0\"):\n        entrypoint_module = torchvision._internally_replaced_utils\n    load_state_dict_from_url = entrypoint_module.load_state_dict_from_url\n\n    def custom_load_state_dict_from_url(url, **kwargs):\n        return load_state_dict_from_url(url, model_dir=model_dir, **kwargs)\n\n    return fou.MonkeyPatchFunction(\n        entrypoint_module,\n        custom_load_state_dict_from_url,\n        fcn_name=load_state_dict_from_url.__name__,\n        namespace=torchvision.models,\n    )\n", "path": "fiftyone/zoo/models/torch.py"}]}