code: def maybe_exclude_networks_from_gradient(self):
      self.set_to_train()
      if self.do_adv_alone:
          no_grad_list = ["trunk", "classifier"]
      elif self.do_metric_alone:
          no_grad_list = ["generator"]
      else:
          no_grad_list = []
      for k in self.models.keys():
          if k in no_grad_list:
              c_f.set_requires_grad(self.models[k], requires_grad=False)
              self.models[k].eval()
          else:
              c_f.set_requires_grad(self.models[k], requires_grad=True)
  
imports: import copy
  import torch
  from ..distances import LpDistance
  from ..losses import TripletMarginLoss
  from ..miners import EmbeddingsAlreadyPackagedAsTriplets
  from ..utils import common_functions
  from ..utils import loss_and_miner_utils
  from .train_with_classifier import TrainWithClassifier
label_desc: Use image node_id 5 for calling the DeepAdversarialMetricLearning obj's underlying member method code with example usage: obj.maybe_exclude_networks_from_gradient() without return types