code: def create_some_context(interactive=None, answers=None):
      if answers is None:
          if "PYOPENCL_CTX" in os.environ:
              ctx_spec = os.environ["PYOPENCL_CTX"]
              answers = ctx_spec.split(":")
  
          if "PYOPENCL_TEST" in os.environ:
              from pyopencl.tools import get_test_platforms_and_devices
  
              for _plat, devs in get_test_platforms_and_devices():
                  for dev in devs:
                      return Context([dev])
  
      if answers is not None:
          pre_provided_answers = answers
          answers = answers[:]
      else:
          pre_provided_answers = None
  
      user_inputs = []
  
      if interactive is None:
          interactive = True
          try:
              if not sys.stdin.isatty():
                  interactive = False
          except Exception:
              interactive = False
  
      def cc_print(s):
          if interactive:
              print(s)
  
      def get_input(prompt):
          if answers:
              return str(answers.pop(0))
          elif not interactive:
              return ""
          else:
              user_input = input(prompt)
              user_inputs.append(user_input)
              return user_input
  
      # {{{ pick a platform
  
      platforms = get_platforms()
  
      if not platforms:
          raise Error("no platforms found")
      else:
          if not answers:
              cc_print("Choose platform:")
              for i, pf in enumerate(platforms):
                  cc_print("[%d] %s" % (i, pf))
  
          answer = get_input("Choice [0]:")
          if not answer:
              platform = platforms[0]
          else:
              platform = None
              try:
                  int_choice = int(answer)
              except ValueError:
                  pass
              else:
                  if 0 <= int_choice < len(platforms):
                      platform = platforms[int_choice]
  
              if platform is None:
                  answer = answer.lower()
                  for pf in platforms:
                      if answer in pf.name.lower():
                          platform = pf
                  if platform is None:
                      raise RuntimeError(
                          "input did not match any platform"
                      )
  
      # }}}
  
      # {{{ pick a device
  
      devices = platform.get_devices()
  
      def parse_device(choice):
          try:
              int_choice = int(choice)
          except ValueError:
              pass
          else:
              if 0 <= int_choice < len(devices):
                  return devices[int_choice]
  
          choice = choice.lower()
          for dev in devices:
              if choice in dev.name.lower():
                  return dev
          raise RuntimeError("input did not match any device")
  
      if not devices:
          raise Error("no devices found")
      elif len(devices) == 1:
          pass
      else:
          if not answers:
              cc_print("Choose device(s):")
              for i, dev in enumerate(devices):
                  cc_print("[%d] %s" % (i, dev))
  
          answer = get_input("Choice, comma-separated [0]:")
          if not answer:
              devices = [devices[0]]
          else:
              devices = [parse_device(i) for i in answer.split(",")]
  
      # }}}
  
      if user_inputs:
          if pre_provided_answers is not None:
              user_inputs = pre_provided_answers + user_inputs
          cc_print(
              "Set the environment variable PYOPENCL_CTX='%s' to "
              "avoid being asked again." % ":".join(user_inputs)
          )
  
      if answers:
          raise RuntimeError(
              "not all provided choices were used by "
              "create_some_context. (left over: '%s')"
              % ":".join(answers)
          )
  
      return Context(devices)
  
imports: from sys import intern
  from warnings import warn
  from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
  from pyopencl.version import VERSION, VERSION_STATUS, VERSION_TEXT
  import pyopencl.cltypes
  import logging
  import os
  import numpy
  import sys
  from pyopencl._cl import get_cl_header_version, program_kind, status_code, platform_info, device_type, device_info, device_topology_type_amd, device_fp_config, device_mem_cache_type, device_local_mem_type, device_exec_capabilities, device_svm_capabilities, command_queue_properties, context_info, gl_context_info, context_properties, command_queue_info, queue_properties, mem_flags, svm_mem_flags, channel_order, channel_type, mem_object_type, mem_info, image_info, pipe_info, pipe_properties, addressing_mode, filter_mode, sampler_info, sampler_properties, map_flags, program_info, program_build_info, program_binary_type, kernel_info, kernel_arg_info, kernel_arg_address_qualifier, kernel_arg_access_qualifier, kernel_arg_type_qualifier, kernel_work_group_info, kernel_sub_group_info, event_info, command_type, command_execution_status, profiling_info, mem_migration_flags, device_partition_property, device_affinity_domain, device_atomic_capabilities, device_device_enqueue_capabilities, version_bits, khronos_vendor_id, Error, MemoryError, LogicError, RuntimeError, Platform, get_platforms, Device, Context, CommandQueue, LocalMemory, MemoryObjectHolder, MemoryObject, MemoryMap, Buffer, _Program, Kernel, Event, wait_for_events, NannyEvent, enqueue_nd_range_kernel, _enqueue_marker, _enqueue_read_buffer, _enqueue_write_buffer, _enqueue_copy_buffer, _enqueue_read_buffer_rect, _enqueue_write_buffer_rect, _enqueue_copy_buffer_rect, _enqueue_read_image, _enqueue_copy_image, _enqueue_write_image, _enqueue_copy_image_to_buffer, _enqueue_copy_buffer_to_image, have_gl, ImageFormat, get_supported_image_formats, Image, Sampler, Pipe
  import inspect
label_desc: Use image node_id 10 for calling a global function with example usage: create_some_context(interactive, answers) and returns: Context, str, str, user_input, devices, dev, Context