code: def _calculate_ranges(
      self,
  ) -> Union[IndexRange, Tuple[IndexRange, IndexRange]]:
      rec_start = None
      rec_stop = -1
      idx_start = 0  # record inner indexing is always sequential
      idx_stop = -1
  
      if self.use_list:
  
          def _update_ranges(trace: Sequence):
              nonlocal rec_start, rec_stop, idx_stop
              rec_start = (
                  min(trace.first_step(), rec_start)
                  if rec_start
                  else trace.first_step()
              )
              rec_stop = max(trace.last_step(), rec_stop)
              idx_stop = max(trace.record_length() or 1, idx_stop)
  
      else:
  
          def _update_ranges(trace: Sequence):
              nonlocal rec_start, rec_stop, idx_stop
              rec_start = (
                  min(trace.first_step(), rec_start)
                  if rec_start
                  else trace.first_step()
              )
              rec_stop = max(trace.last_step(), rec_stop)
  
      self._foreach_trace(_update_ranges)
  
      if self.use_list:
          return IndexRange(rec_start, rec_stop + 1), IndexRange(
              idx_start, idx_stop
          )
      else:
          return IndexRange(rec_start, rec_stop + 1)
  
imports: import asyncio
  import time
  from typing import Iterable, Iterator, List, Tuple, Union, Optional
  from typing import TYPE_CHECKING
  from aim.web.api.runs.utils import ASYNC_SLEEP_INTERVAL, PROGRESS_KEY_SUFFIX, IndexRange, collect_streamable_data, get_run_props, get_run_params
  from aim.web.configs import AIM_PROGRESS_REPORT_INTERVAL
  from aim.sdk.uri_service import URIService, generate_resource_path
  from aim.sdk.sequence_collection import SequenceCollection
  from aim.sdk.sequence import Sequence
  from aim.storage.treeutils import encode_tree
  from aim.storage.context import Context
label_desc: Use image node_id 13 for calling the CustomObjectApi obj's underlying member method code with example usage: obj._calculate_ranges() and returns: IndexRange,  IndexRange, IndexRange