code: def maybe_convert_str_to_mod_type(mod_type: str):
      """
      Convert str to module type
      """
      if not isinstance(mod_type, str):
          return mod_type
      if _re.fullmatch(r"operator\.[a-z]+", mod_type) and hasattr(
          _operator, mod_type.split(".")[-1]
      ):
          return getattr(_operator, mod_type.split(".")[-1])
      elif _re.fullmatch(r"torch\.[a-z]+", mod_type) and hasattr(
          _torch, mod_type.split(".")[-1]
      ):
          return getattr(_torch, mod_type.split(".")[-1])
      elif hasattr(_torch.nn, mod_type):
          return getattr(_torch.nn, mod_type)
      elif hasattr(_torch.nn.functional, mod_type):
          return getattr(_torch.nn.functional, mod_type)
      return mod_type
  
file_path: coremltools/coremltools/optimize/torch/_utils/torch_utils.py
imports: import logging
  import operator
  import re
  from contextlib import contextmanager
  from typing import List
  from typing import Tuple
  from typing import Union
  import numpy
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: maybe_convert_str_to_mod_type(mod_type) and returns: mod_type, mod_type, getattr, getattr, getattr, getattr