code: def _maybe_enter_graph(tensor):
      # Note: might have an eager tensor but not be executing eagerly when
      # building functions.
      if (
          context.executing_eagerly()
          or isinstance(tensor, ops.EagerTensor)
          or ops.has_default_graph()
      ):
          yield
      else:
          with tensor.graph.as_default():
              yield
  
imports: import contextlib
  from tensorflow.python.distribute import packed_distributed_variable
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.tpu import tpu_replication
label_desc: Use image node_id 4 for calling a global function with example usage: _maybe_enter_graph(tensor) without return types