code: def flatten_and_detach_torch_results(torch_results):
      if isinstance(torch_results, (list, tuple)):
          return [
              x.detach().numpy()
              for x in _flatten(torch_results)
              if x is not None
          ]
      elif isinstance(torch_results, dict):
          return [
              value.detach().numpy() for value in torch_results.values()
          ]
      # Do not need to flatten
      return [torch_results.detach().cpu().numpy()]
  
imports: import numpy
  import pytest
  import torch
  import torch.nn
  import coremltools
  import coremltools.models.utils
  from coremltools import RangeDim, TensorType
  from coremltools._deps import _HAS_EXECUTORCH, _HAS_TORCH_EXPORT_API, _IS_MACOS
  from coremltools.converters.mil.mil.types.type_mapping import nptype_from_builtin
  from coremltools.converters.mil.testing_utils import ct_convert, validate_minimum_deployment_target
  from ..ops import TorchFrontend
  from ..torchscript_utils import torch_to_mil_types
label_desc: Use image node_id 8 for calling a global function with example usage: flatten_and_detach_torch_results(torch_results) and returns: list, unknown, unknown