code: def getitem(obj, index):
      """Getitem function
  
      This function creates a copy of the desired selection for array-like
      inputs when the selection is smaller than half of the original array. This
      avoids excess memory usage when extracting a small portion from a large array.
      For more information, see
      https://numpy.org/doc/stable/reference/arrays.indexing.html#basic-slicing-and-indexing.
  
      Parameters
      ----------
      obj: ndarray, string, tuple, list
          Object to get item from.
      index: int, list[int], slice()
          Desired selection to extract from obj.
  
      Returns
      -------
      Selection obj[index]
  
      """
      try:
          result = obj[index]
      except IndexError as e:
          raise ValueError(
              "Array chunk size or shape is unknown. "
              "Possible solution with x.compute_chunk_sizes()"
          ) from e
  
      try:
          if not result.flags.owndata and obj.size >= 2 * result.size:
              result = result.copy()
      except AttributeError:
          pass
  
      return result
  
imports: from __future__ import annotations
  import contextlib
  from collections.abc import Container, Iterable, Sequence
  from functools import wraps
  from numbers import Integral
  import numpy
  from tlz import concat
  from dask.core import flatten
label_desc: Use image node_id 15 for calling a global function with example usage: getitem(obj, index) and returns: result