code: def get_madry_et_al_tf_model(dataname, device="cuda"):
      if dataname == "MNIST":
          weights_path = os.path.join(
              MODEL_PATH, "mnist_challenge/models/secret"
          )
  
          try:
              from mnist_challenge.model import Model
  
              print("mnist_challenge found and imported")
          except (ImportError, ModuleNotFoundError):
              print("mnist_challenge not found, downloading ...")
              os.system(
                  "bash download_mnist_challenge.sh {}".format(
                      MODEL_PATH
                  )
              )
              from mnist_challenge.model import Model
  
              print("mnist_challenge found and imported")
  
          def _process_inputs_val(val):
              return val.view(val.shape[0], 784)
  
          def _process_grads_val(val):
              return val.view(val.shape[0], 1, 28, 28)
  
      elif dataname == "CIFAR10":
          weights_path = os.path.join(
              MODEL_PATH, "cifar10_challenge/models/model_0"
          )
  
          try:
              from cifar10_challenge.model import Model
  
              print("cifar10_challenge found and imported")
          except (ImportError, ModuleNotFoundError):
              print("cifar10_challenge not found, downloading ...")
              os.system(
                  "bash download_cifar10_challenge.sh {}".format(
                      MODEL_PATH
                  )
              )
              from cifar10_challenge.model import Model
  
              print("cifar10_challenge found and imported")
  
          from functools import partial
  
          Model = partial(Model, mode="eval")
  
          def _process_inputs_val(val):
              return 255.0 * val.permute(0, 2, 3, 1)
  
          def _process_grads_val(val):
              return val.permute(0, 3, 1, 2) / 255.0
  
      else:
          raise ValueError(dataname)
  
      def _wrap_forward(forward):
          def new_forward(inputs_val):
              return forward(_process_inputs_val(inputs_val))
  
          return new_forward
  
      def _wrap_backward(backward):
          def new_backward(inputs_val, logits_grad_val):
              return _process_grads_val(
                  backward(
                      _process_inputs_val(*inputs_val), *logits_grad_val
                  )
              )
  
          return new_backward
  
      ptmodel = TorchWrappedModel(
          WrappedTfModel(weights_path, Model), device
      )
      model = BPDAWrapper(
          forward=_wrap_forward(ptmodel.forward),
          backward=_wrap_backward(ptmodel.backward),
      )
  
      return model
  
file_path: advertorch/advertorch_examples/attack_madry_et_al_models/madry_et_al_utils.py
imports: import os
  import sys
  from pathlib import Path
  import tensorflow
  import torch
  from advertorch.bpda import BPDAWrapper
  from advertorch_examples.utils import ROOT_PATH, mkdir
label_desc: Use image node_id 1 for calling a global function with example usage: get_madry_et_al_tf_model(dataname, device) and returns: model, new_forward, new_backward, val, val, forward, _process_grads_val, unknown, unknown