code: def _CreateShapeFromNumpy(ndarray):  # pylint: disable=invalid-name
      """Create a Shape from a given Numpy array.
  
      Args:
        ndarray: Numpy array.
  
      Returns:
        A Shape object.
      """
      element_type = types_.MAP_DTYPE_TO_RECORD[
          str(ndarray.dtype)
      ].primitive_type
      dimensions = ndarray.shape
  
      # Set the shape's layout based on the ordering of ndarray.
      # Numpy arrays come in two orders: Fortran (column-major) and C (row-major).
      if _np.isfortran(ndarray):
          # Column-major layout. This corresponds to a "dimension order is
          # minor-to-major" layout in XLA.
          layout = range(ndarray.ndim)
      else:
          # Row-major layout. This corresponds to a "dimension order is
          # major-to-minor" layout int XLA.
          layout = list(reversed(range(ndarray.ndim)))
  
      return Shape(element_type, dimensions, layout)
  
file_path: tensorflow-upstream/third_party/xla/xla/python_api/xla_shape.py
imports: import numpy
  from local_xla.xla import xla_data_pb2
  from xla.python_api import types_
label_desc: Use image node_id 1 for calling a global function with example usage: _CreateShapeFromNumpy(ndarray) and returns: Shape