(struct, struct_name, size_to_axis_indexer)
return make_struct_indexer(field_indexers)
Returns an object with a `FieldIndexer` attribute for each dynamic field.

  Usage example

  ```python
  named_data = struct_indexer(mjdata, 'mjdata', size_to_axis_indexer)
  fingertip_xpos = named_data.xpos['fingertip']
  elbow_qvel = named_data.qvel['elbow']
  ```

  Args:
    struct: Wrapped ctypes structure as generated by `mjbindings`.
    struct_name: String containing corresponding Mujoco name of struct.
    size_to_axis_indexer: dict that maps size names to `Axis` instances.

  Returns:
    An object with a field for every dynamically sized array field, mapping to a
    `FieldIndexer`. The returned object is immutable and has an `_asdict`
    method.

  Raises:
    ValueError: If `struct_name` is not recognized.
Returns an object with a `FieldIndexer` attribute for each dynamic field.
Returns an object with a FieldIndexer attribute for each dynamic field .
def struct_indexer(struct, struct_name, size_to_axis_indexer):
  """Returns an object with a `FieldIndexer` attribute for each dynamic field.

  Usage example

  ```python
  named_data = struct_indexer(mjdata, 'mjdata', size_to_axis_indexer)
  fingertip_xpos = named_data.xpos['fingertip']
  elbow_qvel = named_data.qvel['elbow']
  ```

  Args:
    struct: Wrapped ctypes structure as generated by `mjbindings`.
    struct_name: String containing corresponding Mujoco name of struct.
    size_to_axis_indexer: dict that maps size names to `Axis` instances.

  Returns:
    An object with a field for every dynamically sized array field, mapping to a
    `FieldIndexer`. The returned object is immutable and has an `_asdict`
    method.

  Raises:
    ValueError: If `struct_name` is not recognized.
  """
  struct_name = struct_name.lower()
  if struct_name not in sizes.array_sizes:
    raise ValueError('Unrecognized struct name ' + struct_name)

  array_sizes = sizes.array_sizes[struct_name]

  # Used to create the namedtuple.
  field_names = []
  field_indexers = {}

  for field_name in array_sizes:

    # Skip over structured arrays and fields that have sizes but aren't numpy
    # arrays, such as text fields and contacts (b/34805932).
    attr = getattr(struct, field_name)
    if not isinstance(attr, np.ndarray) or attr.dtype.fields:
      continue

    size_names = sizes.array_sizes[struct_name][field_name]

    # Here we override the size name in order to enable named column indexing
    # for certain fields, e.g. 3 becomes "xyz" for field name "xpos".
    for new_col_size, field_set in _COLUMN_ID_TO_FIELDS.items():
      if field_name in field_set:
        size_names = (size_names[0], new_col_size)
        break

    axis_indexers = []
    for size_name in size_names:
      axis_indexers.append(size_to_axis_indexer[size_name])

    field_indexers[field_name] = FieldIndexer(
        parent_struct=struct,
        field_name=field_name,
        axis_indexers=axis_indexers)

    field_names.append(field_name)

  return make_struct_indexer(field_indexers)
def struct_indexer ( struct , struct_name , size_to_axis_indexer ) : struct_name = struct_name . lower ( ) if struct_name not in sizes . array_sizes : raise ValueError ( 'Unrecognized struct name ' + struct_name ) array_sizes = sizes . array_sizes [ struct_name ] # Used to create the namedtuple. field_names = [ ] field_indexers = { } for field_name in array_sizes : # Skip over structured arrays and fields that have sizes but aren't numpy # arrays, such as text fields and contacts (b/34805932). attr = getattr ( struct , field_name ) if not isinstance ( attr , np . ndarray ) or attr . dtype . fields : continue size_names = sizes . array_sizes [ struct_name ] [ field_name ] # Here we override the size name in order to enable named column indexing # for certain fields, e.g. 3 becomes "xyz" for field name "xpos". for new_col_size , field_set in _COLUMN_ID_TO_FIELDS . items ( ) : if field_name in field_set : size_names = ( size_names [ 0 ] , new_col_size ) break axis_indexers = [ ] for size_name in size_names : axis_indexers . append ( size_to_axis_indexer [ size_name ] ) field_indexers [ field_name ] = FieldIndexer ( parent_struct = struct , field_name = field_name , axis_indexers = axis_indexers ) field_names . append ( field_name ) return make_struct_indexer ( field_indexers )