code: def _tf_weights_loader(
      dataset, weights_type, layer="DENSE", tf_version=1
  ):
      filename = (
          str(weights_type)
          + "_"
          + str(layer)
          + "_"
          + str(dataset)
          + ".npy"
      )
  
      # pylint: disable=W0613
      # disable pylint because of API requirements for function
      if tf_version == 1:
  
          def _tf_initializer(_, dtype, partition_info):
              import tensorflow as tf
  
              weights = np.load(
                  os.path.join(
                      os.path.dirname(os.path.dirname(__file__)),
                      "utils/resources/models",
                      filename,
                  )
              )
              return tf.constant(weights, dtype)
  
      elif tf_version == 2:
  
          def _tf_initializer(_, dtype):
              import tensorflow as tf
  
              weights = np.load(
                  os.path.join(
                      os.path.dirname(os.path.dirname(__file__)),
                      "utils/resources/models",
                      filename,
                  )
              )
              return tf.constant(weights, dtype)
  
      else:
          raise ValueError(
              "The TensorFlow version tf_version has to be either 1 or 2."
          )
  
      return _tf_initializer
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import json
  import logging
  import os
  import pickle
  import time
  import unittest
  import warnings
  import sklearn
  import numpy
  from art.estimators.classification.tensorflow import TensorFlowV2Classifier
  from art.estimators.encoding.tensorflow import TensorFlowEncoder
  from art.estimators.generation.tensorflow import TensorFlowGenerator, TensorFlowV2Generator
  from art.estimators.gan.tensorflow import TensorFlowV2GAN
  from art.utils import load_dataset
label_desc: Use image node_id 4 for calling a global function with example usage: _tf_weights_loader(dataset, weights_type, layer, tf_version) and returns: _tf_initializer, tf, tf