code: def _method_scope(input_layer, name):
    
    global _in_method_scope
    # pylint: disable=protected-access
  
    with input_layer.g.as_default(), \
         scopes.var_and_name_scope(
             None if _in_method_scope else input_layer._scope), \
         scopes.var_and_name_scope((name, None)) as (scope, var_scope):
      was_in_method_scope = _in_method_scope
      yield scope, var_scope
      _in_method_scope = was_in_method_scope
docs: Creates a nested set of name and id scopes and avoids repeats.