code: def _computations_expand_grid(others: dict) -> dict:
      """
      Creates a cartesian product of all the inputs in `others`.
      Uses numpy's `mgrid` to generate indices, which is used to
      `explode` all the inputs in `others`.
  
      There is a performance penalty for small entries
      in using this method, instead of `itertools.product`;
      however, there are significant performance benefits
      as the size of the data increases.
  
      Another benefit of this approach, in addition to the significant
      performance gains, is the preservation of data types.
      This is particularly relevant for pandas' extension arrays `dtypes`
      (categoricals, nullable integers, ...).
  
      A dictionary of all possible combinations is returned.
      """
  
      for key in others:
          check("key", key, [Hashable])
  
      grid = {}
  
      for key, value in others.items():
          if is_scalar(value):
              value = np.asarray([value])
          elif is_list_like(value) and (not hasattr(value, "shape")):
              value = np.asarray([*value])
          if not value.size:
              raise ValueError(
                  f"Kindly provide a non-empty array for {key}."
              )
  
          grid[key] = value
  
      others = None
  
      # slice obtained here is used in `np.mgrid`
      # to generate cartesian indices
      # which is then paired with grid.items()
      # to blow up each individual value
      # before creating the final DataFrame.
      grid = grid.items()
      grid_index = [slice(len(value)) for _, value in grid]
      grid_index = map(np.ravel, np.mgrid[grid_index])
      grid = zip(grid, grid_index)
      grid = ((*left, right) for left, right in grid)
      contents = {}
      for key, value, grid_index in grid:
          contents.update(_expand_grid(value, grid_index, key))
      # check length of keys and pad if necessary
      lengths = set(map(len, contents))
      if len(lengths) > 1:
          lengths = max(lengths)
          others = {}
          for key, value in contents.items():
              len_key = len(key)
              if len_key < lengths:
                  padding = [""] * (lengths - len_key)
                  key = (*key, *padding)
              others[key] = value
          return others
      return contents
  
imports: from __future__ import annotations
  import fnmatch
  import inspect
  import re
  import warnings
  from collections.abc import Callable
  from dataclasses import dataclass
  from enum import Enum
  from functools import singledispatch
  from typing import Any, Callable, Hashable, Iterable, List, Literal, Optional, Pattern, Union
  import numpy
  import pandas
  from multipledispatch import dispatch
  from pandas.api.types import is_bool_dtype, is_datetime64_dtype, is_list_like, is_scalar, is_string_dtype, union_categoricals
  from pandas.core.common import is_bool_indexer
  from pandas.core.groupby.generic import DataFrameGroupBy, SeriesGroupBy
  from janitor.utils import _expand_grid, check, check_column, find_stack_level
label_desc: Use image node_id 3 for calling a global function with example usage: _computations_expand_grid(others) and returns: contents, others