code: def _monkey_patch_distributed_training_times():
      """Monkey-patches global attributes with subnetwork-specifics ones."""
  
      old_delay_secs_per_worker = (
          training_lib._DELAY_SECS_PER_WORKER
      )  # pylint: disable=protected-access
      old_session_manager = session_manager_lib.SessionManager
      old_min_max_variable_partitioner = (
          partitioned_variables.min_max_variable_partitioner
      )
  
      # monkey-patch global attributes.
      session_manager_lib.SessionManager = SessionManager
      # Override default delay per worker to speed up tests.
      training_lib._DELAY_SECS_PER_WORKER = (
          0.2  # pylint: disable=protected-access
      )
  
      # NOTE: DNNEstimator uses min-max partitioner under the hood which will not
      # partition layers unless they are above a certain size. In order to test that
      # we handle partitioned variables correctly in distributed training we patch
      # the min size to be significantly lower. For more context, see b/133435012
      # and b/136958627. For some reason, creating a custom DNN using a fixed
      # partitioner does not cause the issues described in the bugs so we must test
      # DNNEstimator.
      def patched_min_max_variable_partitioner(
          max_partitions=1,
          axis=0,
          min_slice_size=64,
          bytes_per_string_element=16,
      ):
          del min_slice_size  # Unused, min_slice_size is patched to be constant.
          return old_min_max_variable_partitioner(
              max_partitions=max_partitions,
              axis=axis,
              min_slice_size=64,
              bytes_per_string_element=bytes_per_string_element,
          )
  
      partitioned_variables.min_max_variable_partitioner = (
          patched_min_max_variable_partitioner
      )
  
      try:
          yield
      finally:
          # Revert monkey-patches.
          session_manager_lib.SessionManager = old_session_manager
          training_lib._DELAY_SECS_PER_WORKER = old_delay_secs_per_worker  # pylint: disable=protected-access
          partitioned_variables.min_max_variable_partitioner = (
              old_min_max_variable_partitioner
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import contextlib
  import json
  import os
  import sys
  from absl import app
  from absl import flags
  from absl import logging
  from adanet import tf_compat
  from adanet.autoensemble.estimator import AutoEnsembleEstimator
  from adanet.core.estimator import Estimator
  from adanet.core.evaluator import Evaluator
  from adanet.distributed.placement import RoundRobinStrategy
  from adanet.subnetwork import Builder
  from adanet.subnetwork import SimpleGenerator
  from adanet.subnetwork import Subnetwork
  import tensorflow.compat.v1
  from tensorflow.python.ops import partitioned_variables
  from tensorflow.python.training import session_manager
  from tensorflow_estimator.python.estimator import training
  from tensorflow_estimator.python.estimator.canned import head
label_desc: Use image node_id 1 for calling a global function with example usage: _monkey_patch_distributed_training_times() and returns: old_min_max_variable_partitioner