class_docstr: Base class for Variable.mutable_local
class_docstr_tok: ["Base","class","for","Variable.mutable_local"]
code: def __init__(self, typ: MutableLocalSource):
      # In HigherOrderOperator tracing, we need to distinguish
      # between MutableLocals inside the HigherOrderOperator and
      # ones outside it. For example, it is not safe to mutate
      # `a` in the following example because it was constructed
      # in a different scope.
      #
      # def f(x):
      #     a = 1
      #     def g(x):
      #         nonlocal a
      #         a = 2
      #         return x
      #     return wrap(g, x) + a
      #
      # We use self.scope to distinguish this.
      # scope == 0: The object was an existing variable
      # scope == 1: The object was created while Dynamo
      #             was introspecting a function
      #             (and no HigherOrderOps were involved)
      # scope >= 2: The object was created through
      #             Dynamo introspection of a HigherOrderOp.
      #             The exact number corresponds to the level
      #             of nested HigherOrderOps.
      if typ is MutableLocalSource.Existing:
          self.scope = 0
      elif typ is MutableLocalSource.Local:
          self.scope = current_scope_id()
      else:
          unimplemented(f"Unsupported MutableLocalSource: {typ}")
  
imports: import collections
  from enum import Enum
  from typing import Any, Callable, Dict, List
  from ..None import variables
  from ..current_scope_id import current_scope_id
  from ..exc import unimplemented
  from ..source import AttrSource, Source
  from ..utils import identity, istype
label_desc: Use image node_id 1 to create a new MutableLocalBase object  with example: obj = MutableLocalBase(typ)