code: def select_ranges(
      num_train: int,
      num_test: int,
      dim: int,
      overlap: bool = True,
      nonnegative_only: bool = False,
  ) -> Tuple[Range, Range]:
      """
      Choose disjoint intervals from which to sample points, where
      the test points lie within a region bounded by the region
      that the train points are sampled from.
      """
      choices: npt.NDArray[np.int64] = np.array(
          [0, 1, 2, 5, 10, 20, 50, 100, 200]
      )
  
      def select_index(lst: npt.NDArray[np.int64], val: int) -> int:
          return list((lst - val) >= 0).index(True)
  
      def construct_range(
          index: int, dim: int
      ) -> List[Tuple[int, int]]:
          if nonnegative_only:
              return [(0, choices[index]) for _ in range(dim)]
          return [(-choices[index], choices[index]) for _ in range(dim)]
  
      if nonnegative_only:
          num_points = (choices + 1) ** dim  # list of ints
      else:
          num_points = (2 * choices + 1) ** dim  # list of ints
  
      if overlap:
          train_index = test_index = select_index(
              num_points, num_train + num_test
          )
      else:
          test_index = select_index(num_points, num_test)
          train_index = select_index(
              num_points - num_points[test_index], num_train
          )
  
      test_range = construct_range(test_index, dim)
      train_range = construct_range(train_index, dim)
      return (train_range, test_range)
  
imports: from collections import defaultdict
  from dataclasses import dataclass, field
  from itertools import combinations_with_replacement, product
  import math
  from math import comb
  import numpy
  import numpy.typing
  import random
  import sympy
  from sympy import Symbol, Poly, diff
  from sympy.parsing.sympy_parser import standard_transformations, implicit_multiplication_application
  from typing import List, Optional, Tuple, Dict
  from helm.benchmark.adaptation.adapters.adapter_factory import ADAPT_GENERATION
  from helm.benchmark.adaptation.adapter_spec import AdapterSpec
  from helm.benchmark.window_services.tokenizer_service import TokenizerService
  from helm.common.authentication import Authentication
  from helm.proxy.services.server_service import ServerService
  from .scenario import Scenario, Instance, Reference, TRAIN_SPLIT, TEST_SPLIT, CORRECT_TAG, Input, Output
label_desc: Use image node_id 17 for calling a global function with example usage: select_ranges(num_train, num_test, dim, overlap, nonnegative_only) and returns: train_range,  test_range, list, unknown, unknown