code: def create_buckets_ordered_by_layer(
      nparts_lhs: int,
      nparts_rhs: int,
      order: BucketOrder,
      *,
      generator: random.Random,
  ) -> List[Bucket]:
      """Output buckets in concentric L-shaped layers (e.g., first row + column)
  
      If order is OUTSIDE_IN, start outputting all buckets that have 0 as one of
      their partitions. Once done, output all the ones (among those remaining)
      that have 1 as one of their partitions. After that, those that have 2, and
      so on, until none are left. Each of these stages is called a layer, and
      within each layer buckets are shuffled at random.
  
      For example: [
          (2, 0), (0, 3), (0, 1), (1, 0), (0, 2), (0, 0),  # Layer for 0
          (1, 2), (1, 1), (2, 1), (1, 3),  # Layer for 1
          (2, 2), (2, 3),  # Layer for 2
      ]
  
      If order is INSIDE_OUT, the layers are the same but their order is reversed.
  
      When displaying the layers on a #LHS x #RHS matrix, they have an upside-down
      "L" shape, with the layer for 0 being comprised of the first row and column,
      and the subsequent ones being "nested" inside of it. Graphically:
  
         |  0   1   2   3
      ---+----------------
       0 | L0  L0  L0  L0
       1 | L0  L1  L1  L1
       2 | L0  L1  L2  L2
  
      """
      if (
          order is not BucketOrder.INSIDE_OUT
          and order is not BucketOrder.OUTSIDE_IN
      ):
          raise ValueError("Unknown order: %s" % order)
  
      layers = [
          create_layer_of_buckets(
              nparts_lhs, nparts_rhs, i, generator=generator
          )
          for i in range(min(nparts_lhs, nparts_rhs))
      ]
      if order is BucketOrder.INSIDE_OUT:
          layers.reverse()
      return [b for l in layers for b in l]
  
imports: import logging
  import random
  from abc import ABC, abstractmethod
  from collections import defaultdict
  from statistics import mean
  from typing import Dict, List, NamedTuple, Optional, Set, Tuple
  from torchbiggraph.config import BucketOrder
  from torchbiggraph.distributed import Startable
  from torchbiggraph.rpc import Client, Server
  from torchbiggraph.stats import Stats, StatsHandler
  from torchbiggraph.types import Bucket, EntityName, Partition, Rank, Side
label_desc: Use image node_id 6 for calling a global function with example usage: create_buckets_ordered_by_layer(nparts_lhs, nparts_rhs, order) and returns: unknown