code: def _get_valid_constant(attr, v, owner_type):
      if isinstance(v, _constant_types):
          return v
      elif isinstance(v, (tuple, list)):
          return tuple(
              _get_valid_constant(attr, x, owner_type) for x in v
          )
      constants = ", ".join(
          torch.typename(typ) for typ in _constant_types
      )
      raise TypeError(
          textwrap.dedent(
              f"""
          '{torch.typename(type(v))}' object in attribute '{owner_type}.{attr}' is not a valid constant.
          Valid constants are:
          1. a nn.ModuleList
          2. a value of type {{{constants}}}
          3. a list or tuple of (2)
          """
          )
      )
  
imports: import collections
  import functools
  import inspect
  import sys
  import textwrap
  import types
  import warnings
  from typing import Dict, List, Set, Type
  import torch
  import torch._jit_internal
  from torch._sources import fake_range
  from torch.jit._builtins import _find_builtin
  from torch.jit._check import AttributeTypeIsSupportedChecker
  from torch.jit._state import _add_script_class, _get_script_class, _python_cu
  from torch.jit.frontend import get_class_properties, get_default_args, get_jit_class_def, get_jit_def
  from torch.nn import Module
label_desc: Use image node_id 6 for calling a global function with example usage: _get_valid_constant(attr, v, owner_type) and returns: v, tuple