# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
"""Global configuration/variable scope for autotvm"""


class AutotvmGlobalScope(object):
    current = None

    def __init__(self):
        self._old = AutotvmGlobalScope.current
        AutotvmGlobalScope.current = self

        self.in_tuning = False
        self.silent = False


GLOBAL_SCOPE = AutotvmGlobalScope()


def reset_global_scope(global_scope):
    """Reset global autotvm state. This is needed to initialize PopenPool workers."""
    global GLOBAL_SCOPE
    GLOBAL_SCOPE = global_scope
    AutotvmGlobalScope.current = global_scope

@@ -868,16 +868,53 @@
 bject):%0A
+    %22%22%22The global autotvm scope.%22%22%22%0A%0A
     curr
@@ -924,16 +924,16 @@
  = None%0A
-
 %0A    def
@@ -1099,16 +1099,263 @@
  False%0A%0A
+    def deep_copy(self, global_scope):%0A        %22%22%22Deep copy from another instance of AutotvmGlobalScope.%22%22%22%0A        self._old = AutotvmGlobalScope.current%0A%0A        self.in_tuning = global_scope.in_tuning%0A        self.silent = global_scope.silent%0A%0A
 %0AGLOBAL_
@@ -1549,19 +1549,27 @@
 AL_SCOPE
- = 
+.deep_copy(
 global_s
@@ -1572,16 +1572,17 @@
 al_scope
+)
 %0A    Aut

Fix GLOBAL_SCOPE Shallow copy bug (#9718)