code: def _safe_register_aten_formula(name: str, formula: Formula) -> None:
      """Register a shape inference formula for an aten operator.
  
      Some aten operators are internal and not trusted to be stable.
      This function will raise a warning if the operator is not found.
      """
      # For legacy PyTroch
      suffixes = [".default", ".Tensor", ".dim", ".int"]
      if any(name.endswith(suffix) for suffix in suffixes):
          _safe_register_aten_formula(name.rsplit(".", 1)[0], formula)
  
      names = name.split(".")
      object = torch.ops.aten
      for name in names:
          try:
              if not hasattr(object, name):
                  warnings.warn(
                      f"Cannot find a {name} in torch.ops.aten because {object} has no attribute {name}. "
                      "Skip registering the shape inference formula."
                  )
                  return
          except RuntimeError as e:
              # Some pytorch version will raise RuntimeError when using hasattr
              warnings.warn(
                  f"Fail to register shape inference formula for aten operator {name} because: {e}"
              )
              return
          object = getattr(object, name)
      register_shape_inference_formula(object, formula)
  
imports: from __future__ import annotations
  import logging
  import warnings
  from typing import Callable, Type, Tuple, Any, cast
  import torch
  from torch import nn
  import nni.nas.nn.pytorch
  from nni.mutable import MutableExpression
  from .shape import Formula, ShapeTensor, MutableShape, extract_shape_info, switch_case_shape_info, shape_inference
  from ._attrs import _getattr, tuple_2_t
label_desc: Use image node_id 3 for calling a global function with example usage: _safe_register_aten_formula(name, formula) without return types