code: def main(argv):
      del argv
      tf.config.experimental.set_visible_devices([], "GPU")
  
      seed = FLAGS.seed
      if seed is None:
          import time
  
          seed = np.random.randint(0, 1000000000)
          seed ^= int(time.time())
  
      args = EasyDict(
          arch=FLAGS.arch,
          lr=FLAGS.lr,
          batch=FLAGS.batch,
          weight_decay=FLAGS.weight_decay,
          augment=FLAGS.augment,
          seed=seed,
      )
  
      if FLAGS.expid is not None:
          logdir = "experiment-%d_%d" % (
              FLAGS.expid,
              FLAGS.num_experiments,
          )
      else:
          logdir = "experiment-" + str(seed)
      logdir = os.path.join(FLAGS.logdir, logdir)
  
      if os.path.exists(
          os.path.join(logdir, "ckpt", "%010d.npz" % FLAGS.epochs)
      ):
          print(f"run {FLAGS.expid} already completed.")
          return
      else:
          if os.path.exists(logdir):
              print(
                  f"deleting run {FLAGS.expid} that did not complete."
              )
              shutil.rmtree(logdir)
  
      print(f"starting run {FLAGS.expid}.")
      if not os.path.exists(logdir):
          os.makedirs(logdir)
  
      train, test, xs, ys, keep, nclass = get_data(seed)
  
      # Define the network and train_it
      tm = MemModule(
          network(FLAGS.arch),
          nclass=nclass,
          mnist=FLAGS.dataset == "mnist",
          epochs=FLAGS.epochs,
          expid=FLAGS.expid,
          num_experiments=FLAGS.num_experiments,
          pkeep=FLAGS.pkeep,
          save_steps=FLAGS.save_steps,
          **args,
      )
  
      r = {}
      r.update(tm.params)
  
      open(os.path.join(logdir, "hparams.json"), "w").write(
          json.dumps(tm.params)
      )
      np.save(os.path.join(logdir, "keep.npy"), keep)
  
      tm.train(
          FLAGS.epochs,
          len(xs),
          train,
          test,
          logdir,
          save_steps=FLAGS.save_steps,
      )
  
file_path: privacy/research/mi_poison_2022/train_poison.py
imports: import os
  import shutil
  import json
  import numpy
  import tensorflow
  import tensorflow_datasets
  from absl import app, flags
  from objax.util import EasyDict
  from dataset import DataSet
  from train import augment, MemModule, network
label_desc: Use image node_id 2 for calling a global function with example usage: main(argv) without return types