code: def test_build_fx_feature_extractor(self, model_name):
      set_rng_seed(0)
      model = models.get_model(model_name, **self.model_defaults).eval()
      train_return_nodes, eval_return_nodes = self._get_return_nodes(
          model
      )
      # Check that it works with both a list and dict for return nodes
      self._create_feature_extractor(
          model,
          train_return_nodes={v: v for v in train_return_nodes},
          eval_return_nodes=eval_return_nodes,
      )
      self._create_feature_extractor(
          model,
          train_return_nodes=train_return_nodes,
          eval_return_nodes=eval_return_nodes,
      )
      # Check must specify return nodes
      with pytest.raises(ValueError):
          self._create_feature_extractor(model)
      # Check return_nodes and train_return_nodes / eval_return nodes
      # mutual exclusivity
      with pytest.raises(ValueError):
          self._create_feature_extractor(
              model,
              return_nodes=train_return_nodes,
              train_return_nodes=train_return_nodes,
          )
      # Check train_return_nodes / eval_return nodes must both be specified
      with pytest.raises(ValueError):
          self._create_feature_extractor(
              model, train_return_nodes=train_return_nodes
          )
      # Check invalid node name raises ValueError
      with pytest.raises(ValueError):
          # First just double check that this node really doesn't exist
          if not any(
              n.startswith("l") or n.startswith("l.")
              for n in chain(train_return_nodes, eval_return_nodes)
          ):
              self._create_feature_extractor(
                  model,
                  train_return_nodes=["l"],
                  eval_return_nodes=["l"],
              )
          else:  # otherwise skip this check
              raise ValueError
  
imports: import random
  from itertools import chain
  from typing import Mapping, Sequence
  import pytest
  import torch
  from common_utils import set_rng_seed
  from torchvision import models
  from torchvision.models._utils import IntermediateLayerGetter
  from torchvision.models.detection.backbone_utils import BackboneWithFPN, mobilenet_backbone, resnet_fpn_backbone
  from torchvision.models.feature_extraction import create_feature_extractor, get_graph_node_names
label_desc: Use image node_id 3 for calling the TestFxFeatureExtraction obj's underlying member method code with example usage: obj.test_build_fx_feature_extractor(model_name) without return types