code: def _logical_to_mesh_axes(
      array_dim_names: Optional[Sequence[Optional[str]]],
      rules: Optional[LogicalRules] = None,
  ) -> Optional[List[Union[_UnassignedAxis, None, str, Tuple[str]]]]:
      """Same as logical_to_mesh_axes, but doesn't fill in _unassigned_axis."""
      if array_dim_names is None:
          return None
      if rules is None:
          rules = _axis_rules.rules
      axis_name_counts = collections.Counter(array_dim_names)
      dups = tuple(
          k
          for k, v in axis_name_counts.items()
          if v > 1 and k is not None
      )
      if dups:
          raise ValueError(
              f"Unsupported: Dimensions {dups} occur more than once in array names."
          )
      if not isinstance(rules, (tuple, list)):
          raise ValueError("Unknown axis rule specification type.")
      # We assign mesh axes using a priority based ruleset over logical axis names.
      result: List[Union[_UnassignedAxis, None, str, Tuple[str]]]
      result = [_unassigned_axis] * len(array_dim_names)
      for rule_model_name, rule_mesh_names in rules:
          if rule_model_name in array_dim_names:
              pos = array_dim_names.index(rule_model_name)
              if (
                  _mesh_assignment_free(rule_mesh_names, result)
                  and result[pos] == _unassigned_axis
              ):
                  result[pos] = rule_mesh_names
      return result
  
imports: import collections
  import contextlib
  import dataclasses
  import enum
  import functools
  import threading
  from typing import Any, Callable, List, Optional, Sequence, Tuple, Union
  import jax
  from jax import lax
  from jax.experimental import maps
  from flax import struct
  from flax.core import meta
label_desc: Use image node_id 5 for calling a global function with example usage: _logical_to_mesh_axes(array_dim_names, rules) and returns: result, None