code: def get_attr_wrapped_model(
      model, attr, allow_none=True, return_model_obj=False
  ):
      """Get an attribute from a wrapped model.
      If return_model_obj is true, return the object that has the 'attr' attribute;
      otherwise, return the attribute directly."""
      if isinstance(model, list):
          raise RuntimeError(
              "_get_attr_wrapped_model given a list of models"
          )
  
      if allow_none:
  
          def condition(model, attr):
              return not hasattr(model, attr)
  
      else:
  
          def condition(model, attr):
              return getattr(model, attr, None) is None
  
      while condition(model, attr):
          if not hasattr(model, "module"):
              raise RuntimeError(
                  f"_get_attr_wrapped_model couldn't find attribute {attr}"
              )
  
          model = model.module
  
      if return_model_obj:
          return model
      return getattr(model, attr)
  
imports: import math
  import operator
  from functools import reduce
  import torch
  from megatron.core import parallel_state
  from megatron.core.dist_checkpointing.mapping import ShardedTensor
label_desc: Use image node_id 3 for calling a global function with example usage: get_attr_wrapped_model(model, attr, allow_none, return_model_obj) and returns: getattr, model, unknown, unknown