code: def get_non_empty_subplots(fig, selector):
      gr = fig._validate_get_grid_ref()
      nrows = len(gr)
      ncols = len(gr[0])
      sp_addresses = product(range(nrows), range(ncols))
      # assign a number similar to plotly's xref/yref (e.g, xref=x2) to each
      # subplot address (xref=x -> 1, but xref=x3 -> 3)
      # sp_ax_numbers=range(1,len(sp_addresses)+1)
      # Get those subplot numbers which contain something
      ret = list(
          filter(
              lambda sp: fig._subplot_not_empty(
                  *translate_layout_keys(sp.layout_keys),
                  selector=selector,
              ),
              [gr[r][c][0] for r, c in sp_addresses],
          )
      )
      return ret
  
file_path: plotly.py/packages/python/plotly/plotly/tests/test_core/test_subplots/test_find_nonempty_subplots.py
imports: import pytest
  import plotly.graph_objects
  from plotly.subplots import make_subplots
  from itertools import combinations, product
  from functools import reduce
label_desc: Use image node_id 3 for calling a global function with example usage: get_non_empty_subplots(fig, selector) and returns: ret